0

I have been running into an issue with getting my map displayed using Mapnik XML stylesheets with TileStache. When i am using MBTiles format, the map is displayed perfectly however when i switch over to Mapnik XML styling the map comes out as complete trash and i am not sure why. See images below for difference. Both were exported through Tilemill.

MBTiles Format: enter image description here

Mapnik XML: enter image description here

Below is the current configuration i have set for tilestache.cfg:

{
  "index": "/home/user/tilestache/index.html",
  "cache": {
    "name": "Disk",
    "path": "/tmp/stache",
    "umask": "0000"
  },
  "layers":
  {
    "roads":
    {
      "provider":
      {
        "name": "mapnik",
        "mapfile": "/home/user/tilestache/data/Retry1.xml"
      },
      "projection": "spherical mercator",
      "preview":
      {
        "lat": 39.2891,
        "lon": -76.6135,
        "zoom": 10,
        "ext": "png"
      }
    }
  }
}

I am still fairly new to this.

How can I accomplish a map which looks like the MBTiles format?

UPDATE:

Please see XML code below.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" font-directory="./fonts" background-color="#c4dff6" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">

<Parameters>
  <Parameter name="bounds">-180,-85.0511,180,85.0511</Parameter>
  <Parameter name="center">0,20,4</Parameter>
  <Parameter name="format">png</Parameter>
  <Parameter name="minzoom">0</Parameter>
  <Parameter name="maxzoom">18</Parameter>
  <Parameter name="scale">1</Parameter>
  <Parameter name="metatile">2</Parameter>
  <Parameter name="id"><![CDATA[Retry1]]></Parameter>
  <Parameter name="_updated">1515745392000</Parameter>
  <Parameter name="attribution"><![CDATA[Data © OpenStreetMap (and) contributors, ODbL]]></Parameter>
  <Parameter name="name"><![CDATA[Retry1]]></Parameter>
  <Parameter name="tilejson"><![CDATA[2.0.0]]></Parameter>
  <Parameter name="scheme"><![CDATA[xyz]]></Parameter>
</Parameters>

And some other data from the XML, this file contains much data.

<Layer name="roads_high"
  srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName>roads_high-outline</StyleName>
    <StyleName>roads_high</StyleName>
    <Datasource>
       <Parameter name="dbname"><![CDATA[gis]]></Parameter>
       <Parameter name="extent"><![CDATA[-20037508.34,-20037508.34,20037508.34,20037508.34]]></Parameter>
       <Parameter name="geometry_field"><![CDATA[way]]></Parameter>
       <Parameter name="id"><![CDATA[roads_high]]></Parameter>
       <Parameter name="key_field"><![CDATA[]]></Parameter>
       <Parameter name="project"><![CDATA[osm-bright-master]]></Parameter>
       <Parameter name="srs"><![CDATA[null]]></Parameter>
       <Parameter name="table"><![CDATA[( SELECT way, COALESCE(highway, railway) AS type, 0 AS tunnel, 0 AS bridge, access, 'fill' AS render,
  CASE
    WHEN highway IN ('motorway', 'trunk') THEN 'motorway'
    WHEN highway IN ('primary', 'secondary') THEN 'mainroad'
    WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary', 'tertiary_link', 'residential', 'unclassified', 'road', 'living_street') THEN 'minorroad'
    WHEN highway IN ('service', 'track') THEN 'service'
    WHEN highway IN ('path', 'cycleway', 'footway', 'pedestrian', 'steps', 'bridleway') THEN 'noauto'
    WHEN railway IN ('light_rail', 'subway', 'narrow_gauge', 'rail', 'tram') THEN 'railway'
    ELSE 'other' END AS stylegroup
  FROM planet_osm_line
  WHERE (highway IS NOT NULL OR railway IS NOT NULL)
    AND (tunnel IS NULL OR tunnel = 'no')
    AND (bridge IS NULL OR bridge = 'no')
  ORDER BY z_order
) AS data]]></Parameter>
       <Parameter name="type"><![CDATA[postgis]]></Parameter>
       <Parameter name="user"><![CDATA[postgres]]></Parameter>
    </Datasource>
  </Layer>

<Style name="roads_med" filter-mode="first">
  <Rule>
    <MaxScaleDenominator>750000</MaxScaleDenominator>
    <MinScaleDenominator>400000</MinScaleDenominator>
    <Filter>([type] = 'motorway_link')</Filter>
    <LineSymbolizer stroke-width="0.8" stroke="#e65c5c" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>1500000</MaxScaleDenominator>
    <MinScaleDenominator>750000</MinScaleDenominator>
    <Filter>([type] = 'motorway_link')</Filter>
    <LineSymbolizer stroke-width="0.6" stroke="#e65c5c" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>750000</MaxScaleDenominator>
    <MinScaleDenominator>400000</MinScaleDenominator>
    <Filter>([type] = 'secondary')</Filter>
    <LineSymbolizer stroke-width="0.8" stroke="#ffe873" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>1500000</MaxScaleDenominator>
    <MinScaleDenominator>750000</MinScaleDenominator>
    <Filter>([type] = 'secondary')</Filter>
  • What exactly is missing in the tiles rendered with the mapnik.xml (as far as I can see it is streets and labels, am I right?). Please add some parts of the mapnik.xml and maybe also the corresponding parts of the CartoCss. My guess is that TileMill was not able to convert parts of the styling to the mapnik.xml correctly. – bennos Jan 19 '18 at 11:32
  • Updated. Please let me know what else you would need to see. – MH21209 Jan 21 '18 at 23:41
  • It is difficult to assess the error, even if you would put every line of the *.xml and *.mss. I would check for any differences in between the CartoCss and the mapnk.xml. Another possible source of error is the database connection. Does TileStache have the right connection parameters? Maybe there is some missconfiguration. You could also try with a simpler example to catch differences between the CartoCss and the mapnik.xml. – bennos Jan 22 '18 at 7:34
  • I think i may have missed a crucial part of this based on your response. You mention a .mss file, however i may be completely ignoring that all together. When i exported from tilemill all i had was the XML file, and that is what i using with tilestache right now. Where does this .mss file come into play? Sorry if this seems simple, i am still new to this process. – MH21209 Jan 22 '18 at 19:31
  • When designing your map in Tilemill, you are writing CartoCss to a .mss file. At least I was, when I was working with Tilemill and that's what the screenshot shows at the Tilemill homepage. Tilemill then translates the CartoCss to Mapnik. Why don't you just use MBTiles? They seem to be working. – bennos Jan 22 '18 at 20:41
0

After some experimentation and looking into the logs coming back from uWSGI, it kept saying that it was generating tiles but i could never see anything. The culprit in this case was the XML file since it was using a relative path to refer to where image data was stored. I moved the img directory which was generated to my data directory i created in my Tilestache directory and this resolved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.