Skip to main content

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

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.

Back to the top