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

make_valid throwing errors #358

Open
phil-the-dev opened this issue Jun 1, 2023 · 1 comment
Open

make_valid throwing errors #358

phil-the-dev opened this issue Jun 1, 2023 · 1 comment

Comments

@phil-the-dev
Copy link

I am introducing this gem to a Rails project for the first time, so I'm on the latest version of the gem. I did some digging myself and I don't think this method was ever written for the class. In the code snippet, the class is RGeo::Cartesian::PolygonImpl and the make_valid method just throws an error and nothing else

Steps to reproduce

I used the first code snippet from the Geometry-Validity.md

factory = RGeo::Cartesian.preferred_factory
bowtie_polygon = factory.polygon(factory.linear_ring([factory.point(0, 4),factory.point(4, 4),factory.point(2, 6),factory.point(0, 0),factory.point(0, 4)]))
polygon =
	case bowtie_polygon.invalid_reason
	when RGeo::Error::SELF_INTERSECTION
		bowtie_polygon.make_valid
	when nil # already valid
		bowtie_polygon
	else
		bowtie_polygon.check_validity! # Make sure we raise, undefined behaviour
	end

Expected behavior

The code can run without error

Actual behavior

bowtie_polygon.make_valid throws an error:

RGeo::Error::UnsupportedOperation:
       Method RGeo::Cartesian::PolygonImpl#make_valid not defined.

System configuration

Ruby version: 3.1.4

OS: macOS 13.3.1

@keithdoggett
Copy link
Member

@phil-the-dev do you have geos installed? You can check if it's properly linked by running RGeo::Geos.supported?.

RGeo uses different backends depending on system configuration and what factory you specify. Cartesian factories will try to use geos as a backend if possible, but will fallback to the ruby implementation if it's not available. The geos backend has more methods implemented and is much more performant than the ruby implementation (https://github.com/rgeo/rgeo/blob/main/doc/Factory-Compatibility.md). That table doesn't include make_valid, but I know that we haven't implemented make_valid for ruby backends.

We have plans to bundle geos with the gem and automatically install it to avoid issues like this, but for now unless you're doing a simple project we recommend installing geos yourself and using the geos backend.

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

2 participants