3

I have my own OSM file, which is created by some application which I written.

You can see some of nodes in my OSM file bottom of the post.

I want to fill +/-0.0001 latitude, +/-0.0001 longitude around my point.

I've tried these to style points, however, sadly, height and width attiributes seem to not working :/

What may be the other solution(s) to fill +/-0.0001 lat-long around my point?

layer-amenity-points.xml.inc

<Style name="points">
    <Rule>
      &maxscale_zoom18;
      <Filter>[amenity]='mycustomamenity'</Filter>
      <PointSymbolizer height="52" width="52" file="&symbols;/overlay_img.png" placement="interior"/>
    </Rule>
    <Rule>
      &maxscale_zoom17;
      <Filter>[amenity]='mycustomamenity'</Filter>
      <PointSymbolizer height="26" width="26" file="&symbols;/overlay_img.png" placement="interior"/>
    </Rule>
</Style>

<Layer name="amenity-points" status="on" srs="&osm2pgsql_projection;">
    <StyleName>points</StyleName>
    <Datasource>
      <Parameter name="table">
      (select amenity
      from &prefix;_point
      where amenity is not null
      ) as points</Parameter>
      &datasource-settings;
    </Datasource>
</Layer>

custom.osm

<node id="10000001" lat="0.476527778159" lon="0.999861111111" visible="true">
    <tag k="amenity" v="mycustomamenity"/>
    <tag k="myvalue" v="573"/>
</node>
<node id="10000002" lat="0.476805555937" lon="0.999861111111" visible="true">
    <tag k="amenity" v="mycustomamenity"/>
    <tag k="myvalue" v="576"/>
</node>
<node id="10000003" lat="0.477083333715" lon="0.999861111111" visible="true">
    <tag k="amenity" v="mycustomamenity"/>
    <tag k="myvalue" v="538"/>
</node>

Update

With MarkerSymbolizer in the answer below, I couldn't find how to draw squares. There is just circles can be created by MarkersSymbolizer. I want to draw squares.

2 Answers 2

1

I suggest to use different png symbols for different zoom levels, as it is done with bus stop symbols:

<Rule>
  &maxscale_zoom16;
  &minscale_zoom16;
  <Filter>[amenity]='bus_stop' or [highway]='bus_stop'</Filter>
  <PointSymbolizer file="&symbols;/bus_stop_small.png" placement="interior"/>
</Rule>
<Rule>
  &maxscale_zoom17;
  <Filter>[amenity]='bus_stop' or [highway]='bus_stop'</Filter>
  <PointSymbolizer file="&symbols;/bus_stop.p.12.png" placement="interior"/>
</Rule>

The width and height tags seem to be removed from the PointSybolizer according to the Wiki, but the png can be chosen depending on the zoom level.

6
  • Sadly, I want to give color for different points by using fill property fill="[fillcolor]"
    – Chapuller
    Jun 27, 2014 at 7:58
  • You can add precolored pngs, and set filter rules to get the right one.
    – AndreJ
    Jun 27, 2014 at 8:21
  • No way, generating pngs with all color range #000000 to #FFFFFF is absolutely the wrong thing I can do.
    – Chapuller
    Jun 27, 2014 at 8:26
  • Maybe Mapserver is a better rendering engine for your purpose. Mapnik is a bit weak on data dependent rendering, see sotm-eu.org/slides/2.pdf for a comparison.
    – AndreJ
    Jun 27, 2014 at 8:40
  • Then, what kind of changes I possibly have to make if I decide to move from Mapnik to Mapserver?
    – Chapuller
    Jun 27, 2014 at 8:44
0
+50

First, do you really need to draw squares with these exact dimensions? Or just draw small points?

If it's the latter, use MarkerSymbolizer with given fill, width and height. PointSymbolizer can only display icons, it doesn't look at width/height properties.

If you need a circle at each point with given radius, you can alter the query to return those: select ST_Buffer(way, 11) as way, amenity from ... — but since the data in the PostGIS db is stored in EPSG:3857 format, I presume, you'll have to use meters instead of degrees. 0.0001 degree loosely corresponds to 11 meters at the equator. To render those circles, use a PolygonSymbolizer.

Finally, I noticed your query does not return a geometry column (way for osm2pgsql tables). Is that intended?

8
  • First, thank you for your kind answer. I want to draw squares. I will try to use MarkerSymbolizer. I do not query way column since I thought that I will not need that way column as I do not have any <way> tag in my OSM. Is there a requirement to fetch way column in Query or is it just convention?
    – Chapuller
    Jun 20, 2014 at 10:35
  • Your xml style is obviously based on osm's old mapnik style. It was meant to work with a PostgreSQL/PostGIS database, populated with osm2pgsql. If you are rendering from osm file directly, you obviuosly cannot use SQL queries — but then, why do you have "table" in datasource? way is not a tag in my example, but a column in the planet_osm_point table. It contains feature geometry — where else do you get point coordinates from? Jun 20, 2014 at 11:36
  • As for squares, I guess you'll have to create an SVG and use MarkerSymbolizer with it. There is a way to create squares with exact size in PostGIS, but this margin is to small to outline the solution. Jun 20, 2014 at 11:42
  • 1
    New and old styles differ mainly by format: old one is XML, new one is CartoCSS. Osm2pgsql is always the right way (unless you use Imposm, which is much faster, but doesn't support some features). See MarkerSymbolizer wiki page for examples. Jun 20, 2014 at 11:57
  • 1
    When you are using SVG, you can apply fill directly to objects inside SVG in your vector editor. Fill/width/height properties are placeholders, which generate a simple SVG object in case you don't have another. Jun 20, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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