Markers dropped completely along line when spacing < size #1487

Closed
gravitystorm opened this Issue Sep 14, 2012 · 6 comments

Comments

Projects
None yet
2 participants

When the spacing between markers is less than the marker size, no markers appear at all. I found this surprising, since I'd expect at least some markers to appear, since some can fit in without clashing.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>alpha</StyleName>
        <Datasource>
            <Parameter name="type">geos</Parameter>
            <Parameter name="wkt">LINESTRING(0 0, 10 2)</Parameter>
        </Datasource>
    </Layer>
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>beta</StyleName>
        <Datasource>
            <Parameter name="type">geos</Parameter>
            <Parameter name="wkt">LINESTRING(0 2, 10 4)</Parameter>
        </Datasource>
    </Layer>
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>gamma</StyleName>
        <Datasource>
            <Parameter name="type">geos</Parameter>
            <Parameter name="wkt">LINESTRING(0 4, 10 6)</Parameter>
        </Datasource>
    </Layer>

    <Style name="alpha">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" width="20" height="20" placement="line" spacing="25"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
    <Style name="beta">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" width="20" height="20" placement="line" spacing="20"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
    <Style name="gamma">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" width="20" height="20" placement="line" spacing="15"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
</Map>

http://thunderflames.org/temp/marker-spacing.png - top line is spacing=15

In ASCII, I'd expect something like

-(-X---O---X-)-(-X---O---X-)-(-X---O---X-)-

where (----O----) is a successfully placed marker, O is its center and X is a failed marker position - failed because it clashed with an existing marker.

Tested with a513d3f

Owner

springmeyer commented Jan 4, 2013

revised testcase that uses the csv plugin:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>alpha</StyleName>
        <Datasource>
            <Parameter name="type">csv</Parameter>
            <Parameter name="inline">
            wkt
            "LINESTRING(0 0, 10 2)"
            </Parameter>
        </Datasource>
    </Layer>
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>beta</StyleName>
        <Datasource>
            <Parameter name="type">csv</Parameter>
            <Parameter name="inline">
            wkt
            "LINESTRING(0 2, 10 4)"
            </Parameter>
        </Datasource>
    </Layer>
    <Layer name="layer" srs="+proj=latlong +datum=WGS84">
        <StyleName>gamma</StyleName>
        <Datasource>
            <Parameter name="type">csv</Parameter>
            <Parameter name="inline">
            wkt
            "LINESTRING(0 4, 10 6)"
            </Parameter>
        </Datasource>
    </Layer>

    <Style name="alpha">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" allow-overlap="false" width="20" height="20" placement="line" spacing="25"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
    <Style name="beta">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" allow-overlap="false" width="20" height="20" placement="line" spacing="20"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
    <Style name="gamma">
        <Rule>
            <MarkersSymbolizer file="shape://ellipse" allow-overlap="false" width="20" height="20" placement="line" spacing="15"/>
            <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
        </Rule>
    </Style>
</Map>
Owner

springmeyer commented Jan 4, 2013

With this patch:

diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp
index 164a864..803b235 100644
--- a/include/mapnik/markers_placement.hpp
+++ b/include/mapnik/markers_placement.hpp
@@ -101,7 +101,7 @@ public:
     {
         locator_.rewind(0);
         //Get first point
-        done_ = agg::is_stop(locator_.vertex(&next_x, &next_y)) || spacing_ < marker_width_;
+        done_ = agg::is_stop(locator_.vertex(&next_x, &next_y));
         last_x = next_x;
         last_y = next_y; // Force request of new segment
         error_ = 0;

I can get this rending:

t

Owner

springmeyer commented Jan 4, 2013

@herm - do you recall why spacing_ < marker_width_; is used? Should it be spacing_left < marker_width ?

Owner

springmeyer commented Jan 4, 2013

I think we should likely remove it - appears it has been there from the beginning: 89f6b32#L1R115

Owner

springmeyer commented Jan 4, 2013

with the patch :)

Owner

springmeyer commented Jan 17, 2013

btw, @gravitystorm your testcase for this one also showed a bug in the markers placed on the middle line. They look uneven and this is not right, so I've created #1693.

@PetrDlouhy PetrDlouhy added a commit to PetrDlouhy/mapnik that referenced this issue Aug 22, 2013

@PetrDlouhy Dane Springmeyer + PetrDlouhy fix #1487 (marker placement when spacing < width) and add tests 9531290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment