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

Incorrect 'duplicate consecutive coordinates' error on geo_shape index #17407

Closed
smithsimonj opened this issue Mar 30, 2016 · 4 comments
Closed
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes discuss

Comments

@smithsimonj
Copy link

Description of the problem including expected versus actual behavior:
On Elasticsearch 2.2.1, when loading some geojson shapes into a field indexed with:

"location": {"type": "geo_shape", "precision": "1600m"}

Throws the following error:

Provided shape has duplicate consecutive coordinates at: (180.0, -90.0, NaN)

I believe the geojson is valid and should load fine.

Steps to reproduce:

  1. Load the 'geometry' field of this json blob of Antarctica into a geoshape index

This is a reprise of #14014 but with more details included. I agree with the analysis in that ticket by @danni that this is a artefact of the shape being simplified before being indexed - the 'duplicate consecutive coordinates' being referred to in the error quite simply don't appear even once in the original data.

@clintongormley clintongormley added discuss :Analytics/Geo Indexing, search aggregations of geo points and shapes labels Mar 30, 2016
@smithsimonj
Copy link
Author

I also see the above problem in Elastic 2.3.1

@smithsimonj
Copy link
Author

smithsimonj commented May 13, 2016

Any news on this ticket?

I also see a related bug on this data:

{"type": "polygon", "coordinates": [[[-100.7193347, 37.9217785], [-100.7180306, 37.9207239], [-100.7180379, 37.9202649], [-100.715946, 37.9185112], [-100.7181033, 37.91686], [-100.7208637, 37.9161565], [-100.7264067, 37.9162093], [-100.7290355, 37.9182905], [-100.7289411, 37.9254825], [-100.7370413, 37.9320032], [-100.7344506, 37.9340071], [-100.7299369, 37.9304726], [-100.7249065, 37.9343839], [-100.7248924, 37.944431], [-100.7202908, 37.944422], [-100.7199423, 37.9439893], [-100.7199856, 37.9341727], [-100.7199863, 37.9340851], [-100.7199081, 37.9340847], [-100.7199087, 37.9340092], [-100.7199091, 37.9339619], [-100.7194596, 37.9340074], [-100.7186862, 37.9340038], [-100.7187256, 37.9288659], [-100.7194599, 37.9288675], [-100.7196063, 37.9288697], [-100.7196066, 37.9287782], [-100.7200695, 37.9287791], [-100.7200696, 37.9287473], [-100.7201195, 37.9287474], [-100.7201239, 37.9285088], [-100.7196, 37.9285077], [-100.7196003, 37.9284157], [-100.719624, 37.9282132], [-100.7196325, 37.927568], [-100.7198495, 37.9275697], [-100.7198458, 37.9272774], [-100.7197668, 37.9272145], [-100.7198542, 37.9271518], [-100.7198613, 37.9271555], [-100.7198696, 37.9271479], [-100.7199004, 37.9271347], [-100.7199004, 37.9271115], [-100.7199739, 37.9271115], [-100.7197711, 37.9271115], [-100.719771, 37.9270036], [-100.7197264, 37.9270037], [-100.7197264, 37.9269267], [-100.7197708, 37.9269266], [-100.7197707, 37.9267495], [-100.7198207, 37.9267495], [-100.7198197, 37.9267195], [-100.7197613, 37.9267195], [-100.7197614, 37.9265483], [-100.7197653, 37.9263681], [-100.7192492, 37.9263589], [-100.718921, 37.9263575], [-100.7189234, 37.9260172], [-100.7184264, 37.9260161], [-100.7184245, 37.9258315], [-100.7184284, 37.9253979], [-100.7191241, 37.9254001], [-100.719126, 37.9253251], [-100.7191263, 37.9251287], [-100.7191306, 37.9247127], [-100.719131, 37.9246704], [-100.7193174, 37.9235621], [-100.7193347, 37.9217785]]]}

Error is:

MapperParsingException[failed to parse [location]]; nested: InvalidShapeException[Self-intersection at or near point (-100.7199739, 37.9271115, NaN)];
    at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper.parse(GeoShapeFieldMapper.java:463)
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:309)
    at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:326)
    at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:252)
    at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:122)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
    at org.elasticsearch.index.shard.IndexShard.prepareCreate(IndexShard.java:529)
    at org.elasticsearch.index.shard.IndexShard.prepareCreateOnPrimary(IndexShard.java:506)
    at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:215)
    at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:224)
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:158)
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:66)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:639)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:279)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:271)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
    at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.spatial4j.core.exception.InvalidShapeException: Self-intersection at or near point (-100.7199739, 37.9271115, NaN)
    at com.spatial4j.core.shape.jts.JtsGeometry.validate(JtsGeometry.java:125)
    at org.elasticsearch.common.geo.builders.ShapeBuilder.jtsGeometry(ShapeBuilder.java:94)
    at org.elasticsearch.common.geo.builders.BasePolygonBuilder.build(BasePolygonBuilder.java:165)
    at org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper.parse(GeoShapeFieldMapper.java:446)
    ... 21 more

On elastic 2.3.2

@nknize
Copy link
Contributor

nknize commented Jun 7, 2016

Thanks for the issue @smithsimonj

The second parse exception is not a bug. If you look close at the shape there is a self intersection at [-100.7199739, 37.9271115]. Remove that coordinate and ES is happy.

self-intersection

I'll dig deeper into the Antarctica parse exception. At quick glance there are a handful of coordinates at 180.000000000000171 longitude. This meridian gets translated to a valid -179.999999999999829. There is a close point at [-179.999999999999886, -90.0]. So its possible this is suffering from round-off error but I'll look closer.

@DaveCTurner
Copy link
Contributor

This is a tricky one, but the provided outline of Antarctica is technically not valid GeoJSON because it is oriented clockwise whereas https://tools.ietf.org/html/rfc7946#section-3.1.6 says:

   o  A linear ring MUST follow the right-hand rule with respect to the
      area it bounds, i.e., exterior rings are counterclockwise, and
      holes are clockwise.

It's tricky because ES silently accepts incorrectly-oriented polygons that cross ≤180° of longitude, which is most countries, but Antarctica crosses every line of longitude so this leniency doesn't work any more. Unfortunately, the resulting error message isn't helpful in determining that this was the problem.

The fix is either to correct the orientation of the data to follow the spec, or to alter the mapping to include "orientation": "clockwise". With that change to the mapping, the provided outline is accepted by ES.

I'm going to close this issue and take up the question of how to improve the error message over on #27832.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes discuss
Projects
None yet
Development

No branches or pull requests

4 participants