mapnik / mapnik-support

Use the issues queue here to ask questions and offer help on using Mapnik (maybe if this works well we can retire the mailing list at http://mapnik.org/contact/?)
6 stars 6 forks source link

Issue displaying to layers using XML stylesheet #76

Closed rheh closed 8 years ago

rheh commented 8 years ago

I'm trying to use mapnik to draw a line path over a layer of countries. The problem I'm having is that both work on there own, but, not together. Here is my style:

<?xml version="1.0" encoding="UTF-8"?>
<Map srs="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" background-color="white">

  <Style name="countries">
    <Rule>
      <PolygonSymbolizer fill="rgb(255, 228, 193)" clip="false"/>
      <LineSymbolizer stroke="rgba(77, 163, 148, 0.5)" stroke-width="1" />
    </Rule>

  </Style>

  <Style name="points">
    <Rule>
      <LineSymbolizer  clip="false" stroke="rgba(77, 163, 148, 1)" stroke-width="2" />
    </Rule>
  </Style>

  <Layer status="on" name="world">
    <StyleName>countries</StyleName>
    <Datasource>
      <Parameter name="file">../data/world_merc.json</Parameter>
      <Parameter name="type">geojson</Parameter>
    </Datasource>
  </Layer>

  <Layer status="on" name="routeLine" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>points</StyleName>
    <Datasource>
      <Parameter name="file">../data/routepath.json</Parameter>
      <Parameter name="type">geojson</Parameter>
    </Datasource>
  </Layer>

</Map>

With both I get:

map-merc

And if I remove the map layer from the XML I get:

map

Can anyone see where I am going wrong?

talaj commented 8 years ago

Are both input projections correct? Isn't the line path just too short compared to whole world?

rheh commented 8 years ago

Thanks - I think it is projection related - I spent a few more hours on it yesterday. If I remove the Lambert 93 srs from the map it works; however, it is this projection that I want - not mercator. The data in the countries json is that from the demo projects which I believe is merc projection; thus, I though putting the srs for Lamert 93 on the map would do the necessary transform. But it does n't.

This style-sheet work:

<?xml version="1.0" encoding="UTF-8"?>
<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" background-color="white">

  <Style name="countries">
    <Rule>
      <PolygonSymbolizer fill="rgb(255, 228, 193)" clip="false"/>
      <LineSymbolizer stroke="rgba(77, 163, 148, 0.5)" stroke-width="1" />
    </Rule>

  </Style>
  <Style name="points">
    <Rule>
      <LineSymbolizer  clip="false" stroke="rgba(77, 163, 148, 1)" stroke-width="2" />
    </Rule>
  </Style>

  <Layer status="on" name="world">
    <StyleName>countries</StyleName>
    <Datasource>
      <Parameter name="file">../data/world_merc.json</Parameter>
      <Parameter name="type">geojson</Parameter>
    </Datasource>
  </Layer>

  <Layer status="on" name="routeLine" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>points</StyleName>
    <Datasource>
      <Parameter name="file">../data/routepath.json</Parameter>
      <Parameter name="type">geojson</Parameter>
    </Datasource>
  </Layer>

</Map>

However, as stated I above I was a Lamert 93 projection. How would I achieve this?

Thanks

Ray

talaj commented 8 years ago

Thanks for the info, I will try to reproduce it.

rheh commented 8 years ago

I can supply the geojson files if required?

talaj commented 8 years ago

Why are you insist on Lambert-93? According to spatialreference.org, Lambert-93 is designed for the area of France. I think using such projection for the whole world is not good idea and can cause distortion of geometries in such way they can fall off rendering bounds.

rheh commented 8 years ago

It's the preferred projection in the Aviation world Pilots use aeronautical charts based on LCC because a straight line drawn on a Lambert conformal conic projection approximates a great-circle route between endpoints for typical flight distances.

talaj commented 8 years ago

Yeah, it works well now, when I set srs of the world layer and rendering just bbox of Lambert-93 (-357823.2365, 6037008.6939, 1313632.3628, 7230727.3772):

<Layer status="on" name="world" 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">

_test-1024-768-1 0-agg-reference

Bigger bbox: _test-1024-768-1 0-agg-reference

rheh commented 8 years ago

Many thanks for the assistance. Is this with the LLC projection on the map? As mine still only work with the merc projection on the map layer.

talaj commented 8 years ago

Is this with the LLC projection on the map? As mine still only work with the merc projection on the map layer.

Yes, this is complete style I have used:

<?xml version="1.0" encoding="UTF-8"?>
<Map srs="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" background-color="white">
    <Style name="countries">
        <Rule>
            <PolygonSymbolizer fill="rgb(255, 228, 193)" clip="false"/>
            <LineSymbolizer stroke="rgba(77, 163, 148, 0.5)" stroke-width="1" />
        </Rule>
    </Style>

    <Style name="points">
        <Rule>
            <LineSymbolizer  clip="false" stroke="rgba(77, 163, 148, 1)" stroke-width="2" />
        </Rule>
    </Style>

    <Layer status="on" name="world" 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>countries</StyleName>
        <Datasource>
            <Parameter name="file">world_merc.json</Parameter>
            <Parameter name="type">geojson</Parameter>
        </Datasource>
    </Layer>

    <Layer status="on" name="routeLine" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
        <StyleName>points</StyleName>
        <Datasource>
            <Parameter name="inline">
                wkt
                "LINESTRING(-0.260977596045 51.550861001, 2.33179584146 48.8514328748, 6.90210834146 50.9733894467, 13.4939052165 52.4972462654, 20.9646083415 52.2558018565, 27.4685145915 53.9959037304, 37.5759364665 55.7899327576)"
            </Parameter>
            <Parameter name="type">csv</Parameter>
        </Datasource>
    </Layer>

</Map>
rheh commented 8 years ago

Thanks @talaj it work just fine now.