Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass XML string #7

Open
davenquinn opened this issue Oct 18, 2017 · 2 comments
Open

Can't pass XML string #7

davenquinn opened this issue Oct 18, 2017 · 2 comments

Comments

@davenquinn
Copy link

I'm using node-mapnik 3.6.0 and generate a mapnik XML file shown below using carto

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+init=epsg:3857">


<Style name="terrain" filter-mode="first">
  <Rule>
    <LineSymbolizer stroke="#000000" stroke-width="2" />
  </Rule>
</Style>
<Layer name="terrain"
  srs="+init=epsg:3857">
    <StyleName>terrain</StyleName>
    <Datasource>
       <Parameter name="dbname"><![CDATA[Naukluft]]></Parameter>
       <Parameter name="geometry_field"><![CDATA[geometry]]></Parameter>
       <Parameter name="host"><![CDATA[localhost]]></Parameter>
       <Parameter name="table"><![CDATA[(SELECT id, vertical_geom AS geometry FROM cross_section.section) AS a]]></Parameter>
       <Parameter name="type"><![CDATA[postgis]]></Parameter>
       <Parameter name="srid"><![CDATA[null]]></Parameter>
    </Datasource>
  </Layer>

</Map>

Config (in coffeescript):

strata = tilestrata()

strata
  .layer("geology")
    .route '[email protected]'
    .use tileStrataMapnik {xml: <xml string above>, tileSize: 512, scale: 2 }

strata.listen(39805)

Traceback:

/Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/lib/TileServer.js:519
	var callback = function(err) { if (err) throw err; };
	                                        ^

Error: Unable to initialize "geology" layer: "Path must be a string. Received undefined"
    at /Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/lib/TileServer.js:106:19
    at /Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/node_modules/async/lib/async.js:52:16
    at done (/Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/node_modules/async/lib/async.js:243:17)
    at /Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/node_modules/async/lib/async.js:44:16
    at Immediate._onImmediate (/Users/Daven/Development/Naukluft/versioned/node_modules/tilestrata/lib/TileRequestHandler.js:125:4)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)

When I write the file out and refer to the pathname instead, everything works as expected.

@brianreavis
Copy link
Member

brianreavis commented Oct 18, 2017

Thanks for all this! These lines of tilelive-mapnik seem to be the culprit: https://github.com/mapbox/tilelive-mapnik/blob/v0.6.18/lib/mapnik_backend.js#L208-L211 (which apparently silently fail on old versions of node?).

Could you try using pathname in conjunction with xml (setting it to the path of the xml, as if it were to exist on disk)? This way mapnik will know the base directory. Assuming this works, this should be documented in the readme and I can take care of that.

@davenquinn
Copy link
Author

Hi Brian,

I just tried this, setting pathname: "style.xml" which is a non-existent path name, along with passing xml. This works fine (I guess I would need to specify an existing directory name if I had relative paths in my config).

Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants