Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] Intersection of geometries with different dimensions

I'll call this a bug.  It's definitely a goal to have OverlayNG return geometries with consistent coordinate type even for mixed inputs.

That raises the question: what should be the result coordinate type for mixed inputs?  For Z handling the design decision is to return an XYZ result if either input has Z.  This is to allow "clipping" XYZ geometries by XY geometry.

For geometries with M the situation is less clear, since M values can't necessarily be generated automatically.  

It actually looks like OverlayNG only returns XYZ coordinates for all input coordinate types.  So the only workaround is to reformat the XYZM geometries as XYZ.

On Thu, Jul 22, 2021 at 6:04 PM Glenn Walbran via jts-dev <jts-dev@xxxxxxxxxxx> wrote:

Hi JTS devs

I've had a problem doing a re-projection on a geometry that was the result of an intersection. The problem seems to be because the geometry has a mixed bag of coordinate types. Some are Coordinate, others are CoordinateXYZM.

Looking at https://github.com/locationtech/jts/issues/375 it looks like all the coordinates should be the same type. I'm I correct there?

I made a quick test to show the mixed coordinate types following an intersection operation

  @Test
  public void intersectionPolygonsDifferenctDimensions() {
    Polygon p1 = gf.createPolygon(new Coordinate[]{
      new Coordinate(100, 100),
      new Coordinate(200, 100),
      new Coordinate(200, 200),
      new Coordinate(100, 200),
      new Coordinate(100, 100)
    });

    Polygon p2 = gf.createPolygon(new Coordinate[]{
      new CoordinateXYZM(100, 100, 0, 0),
      new CoordinateXYZM(150, 100, 0, 0),
      new CoordinateXYZM(150, 150, 0, 0),
      new CoordinateXYZM(100, 150, 0, 0),
      new CoordinateXYZM(100, 100, 0, 0)
    });

    Geometry intersection = OverlayNG.overlay(p2, p1, INTERSECTION);
    Map<Class, Integer> coordinateTypes = new HashMap<>();
    for (Coordinate c: intersection.getCoordinates()) {
      coordinateTypes.merge(c.getClass(), 1, (e, v) -> e + v);
    }
    for (Map.Entry<Class, Integer> found: coordinateTypes.entrySet()) {
      System.out.format("%d, %s%n", found.getValue(), found.getKey().getSimpleName());
    }
  }

Regards Glenn

--
Glenn Walbran
Software Developer

Catalyst IT - Expert Open Source Solutions
DDI: +64 4 803 2343 | Mob: +64 21 211 1301 | Tel: +64 4 499 2267 | www.catalyst.net.nz

Catalyst Logo

CONFIDENTIALITY NOTICE: This email is intended for the named recipients only. It may contain privileged, confidential or copyright information. If you are not the named recipient, any use, reliance upon, disclosure or copying of this email or its attachments is unauthorised. If you have received this email in error, please reply via email or call +64 4 499 2267.
_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jts-dev

Back to the top