Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

"Property text-name required for defining text styles." error when numeric filter changes by order of magnitude #411

Closed
amandasaurus opened this issue Nov 30, 2015 · 8 comments
Labels
Milestone

Comments

@amandasaurus
Copy link

This is a very strange error, that can be demonstrated by the openstreetmap-carto style. This happens with carto v0.9.5 from ubuntu's node-carto apt package, and v0.15.5 installed with npm install

Clone the openstreetmap-carto style, and checkout commit 7b8998c089b448dd73e54cd05c2321c99d529b95 - At the time of writing this is the current master.

Carto converts this to Mapnik XML without a problem:

carot project.mml > project.xml

Change line 4 of placenames.mss. In commit 7b8998c it is:

  [admin_level = '2'][zoom >= 3][way_pixels > 1000][way_pixels < 360000] {

Change it to this. We are multiplying the way_pixels numeric filter by 1e-9:

  [admin_level = '2'][zoom >= 3][way_pixels > 0.0000010000][way_pixels < 0.0003600000] {

Carto will convert this project without a problem.

But if you add an extra zero into the way_pixels's filter, i.e. line 4 is now, as if we had multiplied the original by 1e-10:

  [admin_level = '2'][zoom >= 3][way_pixels > 0.00000010000][way_pixels < 0.00003600000] {

Then you get the following error:

Error: placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
    at Object.env.error (/home/rory/openstreetmap-carto/node_modules/carto/lib/carto/parser.js:235:55)
    at Definition.tree.Definition.symbolizersToXML (/home/rory/openstreetmap-carto/node_modules/carto/lib/carto/tree/definition.js:114:17)
    at Definition.tree.Definition.toXML (/home/rory/openstreetmap-carto/node_modules/carto/lib/carto/tree/definition.js:200:29)
    at /home/rory/openstreetmap-carto/node_modules/carto/lib/carto/tree/style.js:31:27
at Array.map (native)
    at Object.tree.StyleXML (/home/rory/openstreetmap-carto/node_modules/carto/lib/carto/tree/style.js:30:29)
    at Renderer.render (/home/rory/openstreetmap-carto/node_modules/carto/lib/carto/renderer.js:130:39)
    at compileMML (/home/rory/openstreetmap-carto/node_modules/carto/bin/carto:74:31)
    at Object.<anonymous> (/home/rory/openstreetmap-carto/node_modules/carto/bin/carto:156:9)
    at Module._compile (module.js:456:26)
@nebulon42 nebulon42 added the bug label Feb 27, 2016
@nebulon42
Copy link
Collaborator

I think this is a duplicate of #369.
@rory Would you be able to test if latest master fixes this issue for you?

@nebulon42
Copy link
Collaborator

Closing for now.

@amandasaurus
Copy link
Author

I'm not experienced with npm. I ran this in an openstreetmap-carto directory with the appropriate change, and got this error:

$ npm install mapbox/carto
[snip]
$ ./node_modules/.bin/carto project.mml
Error: placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
placenames.mss:24:6 Property text-name required for defining text styles.
placenames.mss:21:6 Property text-name required for defining text styles.
placenames.mss:18:6 Property text-name required for defining text styles.
placenames.mss:15:6 Property text-name required for defining text styles.
placenames.mss:12:6 Property text-name required for defining text styles.
    at Object.env.error (/tmp/openstreetmap-carto/node_modules/carto/lib/carto/parser.js:241:55)
    at Definition.tree.Definition.symbolizersToXML (/tmp/openstreetmap-carto/node_modules/carto/lib/carto/tree/definition.js:114:17)
    at Definition.tree.Definition.toXML (/tmp/openstreetmap-carto/node_modules/carto/lib/carto/tree/definition.js:203:33)
    at /tmp/openstreetmap-carto/node_modules/carto/lib/carto/tree/style.js:31:27
    at Array.map (native)
    at Object.tree.StyleXML (/tmp/openstreetmap-carto/node_modules/carto/lib/carto/tree/style.js:30:29)
    at Renderer.render (/tmp/openstreetmap-carto/node_modules/carto/lib/carto/renderer.js:130:39)
    at compileMML (/tmp/openstreetmap-carto/node_modules/carto/bin/carto:87:31)
    at Object.<anonymous> (/tmp/openstreetmap-carto/node_modules/carto/bin/carto:175:9)

That means it hasn't been fixed, right?
at Module._compile (module.js:456:26)

@nebulon42
Copy link
Collaborator

@rory It (probably) has been fixed in master, but there was no new release yet. So if you use the NPM version the bug is still there. To test and confirm this you would have to clone this repository and invoke bin/carto from there.

@amandasaurus
Copy link
Author

I have checked out the carto master and did a npm install . there and then ran ./bin/carto on the project.mml and I got the same error. I don't think this has been fixed.

@nebulon42
Copy link
Collaborator

Thanks for taking the time to verify it. I could reproduce it. Not sure if it is a bug as such with the very small way pixels, but there should definitely be another error message.

@nebulon42 nebulon42 reopened this Mar 8, 2016
@nebulon42 nebulon42 added this to the 0.17 milestone Dec 11, 2016
nebulon42 added a commit that referenced this issue Dec 25, 2016
@nebulon42
Copy link
Collaborator

For my documentation: So far I have traced the bug to the addRules function (https://github.com/mapbox/carto/blob/master/lib/carto/renderer.js#L245).

The definitions of the test case in both cases are nearly (superficially) identical (except for specificity):

[ Definition {
    elements: [ [Object] ],
    rules: [ [Object] ],
    ruleIndex: { '67108848#__default__#text-size': true },
    filters: Filterset { filters: [Object] },
    zoom: 67108848,
    attachment: '__default__',
    specificity: [ 1, 0, 4, 166 ] },
  Definition {
    elements: [ [Object] ],
    rules: [ [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    zoom: 67108856,
    attachment: '__default__',
    specificity: [ 1, 0, 3, 90 ] },
  Definition {
    elements: [ [Object] ],
    rules: [],
    ruleIndex: {},
    filters: Filterset { filters: {} },
    zoom: 67108863,
    attachment: '__default__',
    specificity: [ 1, 0, 0, 0 ] } ]

[ Definition {
    elements: [ [Object] ],
    rules: [ [Object] ],
    ruleIndex: { '67108848#__default__#text-size': true },
    filters: Filterset { filters: [Object] },
    zoom: 67108848,
    attachment: '__default__',
    specificity: [ 1, 0, 4, 150 ] },
  Definition {
    elements: [ [Object] ],
    rules: [ [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    zoom: 67108856,
    attachment: '__default__',
    specificity: [ 1, 0, 3, 74 ] },
  Definition {
    elements: [ [Object] ],
    rules: [],
    ruleIndex: {},
    filters: Filterset { filters: {} },
    zoom: 67108863,
    attachment: '__default__',
    specificity: [ 1, 0, 0, 0 ] } ]

The output is considerably different. Error case:

current
[ Definition {
    elements: [ [Object] ],
    rules: [ [Object] ],
    ruleIndex: { '67108848#__default__#text-size': true },
    filters: Filterset { filters: [Object] },
    zoom: 67108848,
    attachment: '__default__',
    specificity: [ 1, 0, 4, 166 ] } ]
current
[ Definition {
    rules: [ [Object] ],
    ruleIndex: { '67108848#__default__#text-size': true },
    filters: Filterset { filters: [Object] },
    attachment: '__default__' } ]
current
[ Definition {
    rules: [ [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    attachment: '__default__' } ]

Reference case:

current
[ Definition {
    rules: [ [Object], [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108848#__default__#text-size': true,
       '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    attachment: '__default__' } ]
current
[ Definition {
    rules: [ [Object], [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108848#__default__#text-size': true,
       '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    attachment: '__default__' } ]
current
[ Definition {
    rules: [ [Object], [Object], [Object], [Object] ],
    ruleIndex: 
     { '67108856#__default__#text-name': true,
       '67108856#__default__#text-size': true,
       '67108856#__default__#text-fill': true,
       '67108856#__default__#text-face-name': true },
    filters: Filterset { filters: [Object] },
    attachment: '__default__' } ]

@nebulon42
Copy link
Collaborator

This was a tough one for me to fix. The fix itself is very easy, a regular expression was used to decide if a filter value should be parsed as number or not. It turned out that this expression did not match all possibilities. But getting there took a bit of time. Anyway: should be fixed and probably also covers some other odd cases.

nebulon42 added a commit that referenced this issue May 1, 2017
… for strings that begin with a number, but shouldn't be treated as one
nebulon42 added a commit that referenced this issue May 1, 2017
… for strings that begin with a number, but shouldn't be treated as one
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants