calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
734 stars 229 forks source link

handle out of order rings #206

Closed calvinmetcalf closed 6 months ago

calvinmetcalf commented 6 months ago

@chaensel-agco if you had a good example shapefile that would be helpful

chaensel-agco commented 6 months ago

I will try to organize an example file beginning next week.

chaensel-agco commented 6 months ago

This zip file should contain a shape with one outer boundary and and one inner boundary. The outer boundary covers an area of ~ 2.32 ha, the cut out is about 0.25 ha. So the expected total area of this polygon is ~ 2.07 ha (2.32 - 0.25).

This is how the parts are actually returned by the library and therefore probably stored in the original data. (first one is the inner boundary and the second one the outer boundary).

parts= [
  [
    [ 4.175108456990789, 50.9335905756178 ],
    [ 4.175855793597216, 50.93384800246855 ],
    [ 4.175577723225728, 50.93430254838218 ],
    [ 4.174960788313562, 50.93393562475715 ],
    [ 4.175108456990789, 50.9335905756178 ]
  ],
  [
    [ 4.176121093595888, 50.933204489347595 ],
    [ 4.175677907699802, 50.93275537380509 ],
    [ 4.174139707300726, 50.93375765952205 ],
    [ 4.175655964242284, 50.93487202806504 ],
    [ 4.177111786743469, 50.93356597773318 ],
    [ 4.1765381991531205, 50.93343448651637 ],
    [ 4.176121093595888, 50.933204489347595 ]
  ]
]

SHP_Exclude.zip

calvinmetcalf commented 6 months ago

ok great thanks, I'm using this as an opertunity to also clean some stuff up and modernize so i should have a major version out sometime thing week

chaensel-agco commented 6 months ago

@calvinmetcalf I tested the changes locally and it looks promising to me.