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

GeoJSON plugin sometimes reversing order of features #3182

Closed
danpat opened this issue Nov 21, 2015 · 6 comments
Closed

GeoJSON plugin sometimes reversing order of features #3182

danpat opened this issue Nov 21, 2015 · 6 comments
Assignees
Milestone

Comments

@danpat
Copy link
Contributor

danpat commented Nov 21, 2015

In some circumstances, it seems that the geojson datasource plugin is not maintaining feature ordering.

I am drawing LineString features from a GeoJSON file on a map, colouring them based on an "age" property. The features are listed in chronological order in the GeoJSON file. I rely on the latter features being painted over the top of the earlier features to composite the final image.

If I load the GeoJSON with the ogr plugin, I get the following correct rendering:

screen shot 2015-11-21 at 13 30 22

However, if I use the geojson datasource plugin, I sometimes see this, for the same data/stylesheets:

screen shot 2015-11-21 at 13 29 19

I'm having difficulty coming up with a minimal reproduction case, but the only change between the two above it the datasource type, the datafile and stylesheet remained the same.

In all cases, the "green" data is listed later in the GeoJSON. The second image hints that the ordering of the features is somewhat randomized, it does not appear to be strictly reversed.

The above results were achieved with tilelive-mapnik using mapnik@3.4.10.

@danpat
Copy link
Contributor Author

danpat commented Nov 22, 2015

More info: it looks like it's a combination of geojson and cache_features that causes this mis-ordering.

The following causes the problem:

<Layer name="grooming" srs="+init=epsg:4326">
    <StyleName>grooming</StyleName>
    <Datasource>
       <Parameter name="type">geojson</Parameter>
       <Parameter name="file">grooming.geojson</Parameter>
       <Parameter name="cache_features">true</Parameter>
    </Datasource>
</Layer>

flipping cache_features makes it go away.

@artemp artemp self-assigned this Nov 23, 2015
@artemp artemp added this to the Mapnik 3.0.9 milestone Nov 23, 2015
artemp added a commit that referenced this issue Nov 23, 2015
@artemp
Copy link
Member

artemp commented Nov 23, 2015

@danpat - good catch! aee0149 should fix the issue, could you verify with your dataset and I'll close this issue.

@springmeyer
Copy link
Member

@danpat can you help reduce a regression testcase? The idea would be to craft an xml+geojson that triggered the issue, check the xml into https://github.com/mapnik/test-data-visual, and the geojson into https://github.com/mapnik/test-data, then ensure it is fixed by @artemp's commit. Once you have that confirmation then we'ed update mapnik master to point at the new test data by updating the git submodules.

@artemp
Copy link
Member

artemp commented Nov 25, 2015

@danpat @springmeyer - this is asking for a unit test not a visual one!! I'm working on it

@artemp
Copy link
Member

artemp commented Nov 25, 2015

unit test is in place ^, closing

@artemp artemp closed this as completed Nov 25, 2015
@springmeyer
Copy link
Member

Excellent!. Confirmed that if I revert the bugfix (aee0149) I get a failure as expected now:

test/unit/datasource/geojson.cpp:621: FAILED:
  REQUIRE( val.get<mapnik::value_integer>() == ++count )
with expansion:
  19 == 1

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

No branches or pull requests

3 participants