zellige / hs-geojson

GeoJSON parsing library [Haskell]
BSD 3-Clause "New" or "Revised" License
23 stars 13 forks source link

Polygon Definition lacks 1 more level of list #2

Closed amcvega closed 10 years ago

amcvega commented 10 years ago

based on http://geojson.org/geojson-spec.html#polygon GeoPolygon lacks 1 more level of coordinates to make it an "array of LinearRing coordinate arrays" and compatible with the spec.

I rectified it with a quick fix (https://github.com/amcvega/hs-geojson/commit/8f0c4c0ae4b76d8c2d3af3372ce9c40bb7b58a16) in the GeoPolygon.hs. Tried making the tests pass again but got stumped by the bigAssFeatureCollectionJSON test.

Great work! This package is a life-saver.

domdere commented 10 years ago

Ah ok, thanks, I'll look at it tonight :)

domdere commented 10 years ago

I've started my fix in the polygon-fix branch I'll put the LinearRing type in the GeoPolygon and fix all the tests tomorrow night.

domdere commented 10 years ago

I've got a fix in the referenced pull request, which I will merge in tomorrow if you dont see any problems with it :)

The LinearRing enforces the length of the "LinearRings" the spec describes. Later I will probably modify it to also compare the first and last element of the vector in the JSON Value and double check they are "equal", though I'm a bit hesitant to do that since the most common use cases is going to involve Doubles.

In any case, it wont affect the interface and when/if i do that it can be a minor point release.

I'll probably also do something similar with the Line objects to ensure that they are at least 2 elements long, further down the track.