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

GEOS cuts LineString by short direct lines, after difference with Polygon #134

Open
Surzhikov opened this issue Oct 1, 2016 · 1 comment

Comments

@Surzhikov
Copy link

Hi, Thank you for GeoPHP.
I found a strange behavior of geos. Maybe you can help me.

I got 2 objects: Polygon and LineString (loaded from valid GeoJSON).

Polygon: GeoJSON
MAP Screenshot

LineString: GeoJSON
MAP Screenshot

I want to CUT LineString by Polygon;
So i do:

/* Getting JSONs from files */
$PolygonJson = file_get_contents("PolygonJson.json");
$LineStringJson = file_get_contents("LineStringJson.json");

/* geoPHP instances */
$Polygon = geoPHP::load($PolygonJson,'json');
$LineString = geoPHP::load($LineStringJson,'json');

/* geos */
$Polygon_geos = $Polygon->geos();
$LineString_geos = $LineString->geos();

/* difference */
$difference_geos = $LineString_geos->difference($Polygon_geos);
$difference = geoPHP::geosToGeometry($difference_geos);
$differeceGeoJSONArray = json_decode($difference->out('json'), true);
file_put_contents("difference.json", $difference->out('json'));

I expect to get MultiLineString object (with 3 LineStrings), but I get 2 normal (fully, intact) LineStrings and 1 cropped LineString (it cropped by short direct LineString of 2 points).

difference.json: GeoJSON,
MAP Screenshot
At the first see - it is OK

MAP Screenshot

But Zoomed MAP Screenshot - line is non-intact :(((

issue description: geos crops LineString for short (2 points) direct lines.

@Surzhikov
Copy link
Author

update:
Cut points - is the point of "self-intersection" (of the StringLine)

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

No branches or pull requests

1 participant