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

Question: Is there a way to determine geometry dimension? #654

Open
hisener opened this issue Dec 21, 2020 · 2 comments
Open

Question: Is there a way to determine geometry dimension? #654

hisener opened this issue Dec 21, 2020 · 2 comments

Comments

@hisener
Copy link
Contributor

hisener commented Dec 21, 2020

The WKBWriter constructor expects output dimension (e.g. new WKBWriter(dimension, ByteOrderValues.LITTLE_ENDIAN, true)) and it has to be either 2 or 3. However, Geometry#getDimension is not appropriate to use here. Is there a generic way to determine the dimension for a given Geometry object? In other words, is there such method that satisfies the following:

  • #getDimension(GEOMETRY_FACTORY.createPoint(new Coordinate(1,2))) -> 2
  • #getDimension(GEOMETRY_FACTORY.createPoint(new Coordinate(1,2,3))) -> 3
  • #getDimension(GEOMETRY_FACTORY.createPolygon(new Coordinate[]{new Coordinate(1,2,3), new Coordinate(2,2,3), new Coordinate(2,3,3), new Coordinate(1,2,3)})) -> 3
  • #getDimension(GEOMETRY_FACTORY.createMultiPolygon(new Polygon[]{GEOMETRY_FACTORY.createPolygon(new Coordinate[]{new Coordinate(1,2,3), new Coordinate(2,2,3), new Coordinate(2,3,3), new Coordinate(1,2,3)})})) -> 3

where #getDimension accepts Geometry.

@dr-jts
Copy link
Contributor

dr-jts commented Jan 22, 2021

There isn't anything like this now, but this method would be useful for sure.

@dbaston
Copy link
Contributor

dbaston commented Jan 23, 2021

GEOS has Geometry::getCoordinateDimension that could be ported back.

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

No branches or pull requests

3 participants