Beispiel #1
0
  @Override
  public void applyTransformation(Transformation2D transform) {
    if (isEmptyImpl()) return;

    Point2D pt = getXY();
    transform.transform(pt, pt);
    setXY(pt);
  }
Beispiel #2
0
 /**
  * Sets the XY coordinates of this point. param pt The point to create the X and Y coordinate
  * from.
  */
 void setXY(Point2D pt) {
   _touch();
   setXY(pt.x, pt.y);
 }
Beispiel #3
0
 /**
  * Creates a 2D Point with specified X and Y coordinates. In case of Geographic Coordinate
  * Systems, the X coordinate is the longitude and the Y is the latitude.
  *
  * @param x The X coordinate of the new 2D point.
  * @param y The Y coordinate of the new 2D point.
  */
 public Point(double x, double y) {
   m_description = VertexDescriptionDesignerImpl.getDefaultDescriptor2D();
   setXY(x, y);
 }
  @Test
  public static void testCreation() {
    { // simple create
      MultiPoint mpoint = new MultiPoint();
      assertTrue(mpoint.getClass() == MultiPoint.class);
      // assertFalse(mpoint.getClass() == Polyline.class);

      assertTrue(mpoint != null);
      assertTrue(mpoint.getType() == Geometry.Type.MultiPoint);
      assertTrue(mpoint.isEmpty());
      assertTrue(mpoint.getPointCount() == 0);
      mpoint = null;
      assertFalse(mpoint != null);
    }
    { // play with default attributes
      MultiPoint mpoint = new MultiPoint();
      simpleTest(mpoint);
    }

    { // simple create 2D
      MultiPoint mpoint = new MultiPoint();
      assertTrue(mpoint != null);

      // FIXME uncomment when assertions are fixed
      // try
      // {
      // // OutputDebugString(L"Test an assert\n");
      // // GeometryException::m_assertOnException = false;
      //
      // Point pt2 = mpoint.getPoint(0);;
      // }
      // catch(GeometryException except)
      // {
      // assertTrue(except.index_out_of_bounds);
      // GeometryException::m_assertOnException = true;
      // }

      MultiPoint mpoint1 = new MultiPoint();
      assertTrue(mpoint1 != null);
      // FIXME uncomment when assertions are fixed
      // try
      // {
      // OutputDebugString(L"Test an assert\n");
      // GeometryException::m_assertOnException = false;
      // Point ppp;
      // mpoint.getPointByVal(0, ppp);
      // }
      // catch(GeometryException except)
      // {
      // assertTrue(except.index_out_of_bounds);
      // GeometryException::m_assertOnException = true;
      // }

      mpoint.setEmpty();
      Point pt = new Point(0, 0);
      mpoint.add(pt);
      Point pt3 = mpoint.getPoint(0);
      assertTrue(
          pt3.getX() == 0 && pt3.getY() == 0
          /** && pt3.getZ() == 0 */
          );
      // assertFalse(mpoint->HasAttribute(VertexDescription::Semantics::Z));
      // pt3.setZ(115.0);
      mpoint.setPoint(0, pt3);
      pt3 = mpoint.getPoint(0);
      assertTrue(pt3.getX() == 0 && pt3.getY() == 0 /* && pt3.getZ() == 115 */);
      // assertTrue(mpoint->HasAttribute(VertexDescription::Semantics::Z));
      // CompareGeometryContent(mpoint, &pt, 1);
    }

    { // move 3d
      MultiPoint mpoint = new MultiPoint();
      assertTrue(mpoint != null);
      Point pt = new Point(0, 0);
      mpoint.add(pt);
      Point pt3 = mpoint.getPoint(0);
      assertTrue(pt3.getX() == 0 && pt3.getY() == 0 /* && pt3.getZ() == 0 */);
      // assertFalse(mpoint->HasAttribute(VertexDescription::Semantics::Z));
      // FIXME once transform3D is public
      // Transformation3D transform3D = GCNEW Transformation3D;
      // transform3D.setTranslate(1, 1, 0);
      // mpoint.applyTransformation(transform3D);

      // assertTrue(mpoint->HasAttribute(VertexDescription::Semantics::Z));
      // pt3 = mpoint.getPoint(0);
      // assertTrue(pt3.x == 1 && pt3.y == 1 && pt3.z == 0);
      // transform3D.setTranslate(56, 12, 333);
      // mpoint.applyTransformation(transform3D);
      // pt3 = mpoint.getXYZ(0);
      // assertTrue(pt3.x == 57 && pt3.y == 13 && pt3.z == 333);
      // CompareGeometryContent(mpoint, &pt3, 1);
    }

    { // test QueryInterval
      MultiPoint mpoint = new MultiPoint();

      Point pt1 = new Point(0.0, 0.0);
      // pt1.setZ(-1.0);

      Point pt2 = new Point(0.0, 0.0);
      // pt2.setZ(1.0);

      mpoint.add(pt1);
      mpoint.add(pt2);

      // Envelope1D e =
      // mpoint->QueryInterval(enum_value2(VertexDescription, Semantics,
      // Z), 0);
      Envelope e = new Envelope();
      mpoint.queryEnvelope(e);
      // assertTrue(e.get == -1.0 && e.vmax == 1.0);
    }

    {
      @SuppressWarnings("unused")
      MultiPoint geom = new MultiPoint();
      // int sz = sizeof(openString) / sizeof(openString[0]);
      // for (int i = 0; i < sz; i++)
      // geom.add(openString[i]);
      // CompareGeometryContent(geom, openString, sz);
    }

    {
      @SuppressWarnings("unused")
      MultiPoint geom = new MultiPoint();
      // int sz = sizeof(openString) / sizeof(openString[0]);
      // Point point = GCNEW Point;
      // for (int i = 0; i < sz; i++)
      // {
      // point.setXY(openString[i]);
      // geom.add(point);
      // }
      // CompareGeometryContent(geom, openString, sz);
    }

    // Test AddPoints
    {
      @SuppressWarnings("unused")
      MultiPoint geom = new MultiPoint();
      // int sz = sizeof(openString) / sizeof(openString[0]);
      // geom.addPoints(openString, sz, 0, -1);
      // CompareGeometryContent((MultiVertexGeometry)geom, openString,
      // sz);
    }

    // Test InsertPoint(Point2D)
    {
      MultiPoint mpoint = new MultiPoint();
      Point pt0 = new Point(0.0, 0.0);
      // pt0.setZ(-1.0);
      // pt0.setID(7);

      Point pt1 = new Point(0.0, 0.0);
      // pt1.setZ(1.0);
      // pt1.setID(11);

      Point pt2 = new Point(0.0, 1.0);
      // pt2.setZ(1.0);
      // pt2.setID(13);

      mpoint.add(pt0);
      mpoint.add(pt1);
      mpoint.add(pt2);

      Point pt3 = new Point(-11.0, -13.0);

      mpoint.add(pt3);
      mpoint.insertPoint(1, pt3);
      assertTrue(mpoint.getPointCount() == 5);

      Point pt;
      pt = mpoint.getPoint(0);
      assertTrue(pt.getX() == pt0.getX() && pt.getY() == pt0.getY() /*
																		 * &&
																		 * pt.
																		 * getZ
																		 * () ==
																		 * pt0
																		 * .getZ
																		 * ()
																		 */);

      pt = mpoint.getPoint(1);
      assertTrue(pt.getX() == pt3.getX() && pt.getY() == pt3.getY());

      pt = mpoint.getPoint(2);
      assertTrue(pt.getX() == pt1.getX() && pt.getY() == pt1.getY() /*
																		 * &&
																		 * pt.
																		 * getZ
																		 * () ==
																		 * pt1
																		 * .getZ
																		 * ()
																		 */);

      pt = mpoint.getPoint(3);
      assertTrue(pt.getX() == pt2.getX() && pt.getY() == pt2.getY() /*
																		 * &&
																		 * pt.
																		 * getZ
																		 * () ==
																		 * pt2
																		 * .getZ
																		 * ()
																		 */);

      Point point = new Point();
      point.setXY(17.0, 19.0);
      // point.setID(12);
      // point.setM(5);

      mpoint.insertPoint(2, point);
      mpoint.add(point);

      assertTrue(mpoint.getPointCount() == 7);

      // double m;
      // int id;
      // pt = mpoint.getXYZ(2);
      // assertTrue(pt.x == 17.0 && pt.y == 19.0 && pt.z == defaultZ);
      // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription,
      // Semantics, M), 2, 0);
      // assertTrue(m == 5);
      // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription,
      // Semantics, ID), 2, 0);
      // assertTrue(id == 23);
      //
      // pt = mpoint.getXYZ(3);
      // assertTrue(pt.x == pt1.x && pt.y == pt1.y && pt.z == pt1.z);
      // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription,
      // Semantics, M), 3, 0);
      // assertTrue(NumberUtils::IsNaN(m));
      // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription,
      // Semantics, ID), 3, 0);
      // assertTrue(id == 11);
    }

    MultiPoint mpoint = new MultiPoint();
    Point pt0 = new Point(0.0, 0.0, -1.0);

    Point pt1 = new Point(0.0, 0.0, 1.0);

    Point pt2 = new Point(0.0, 1.0, 1.0);

    mpoint.add(pt0);
    mpoint.add(pt1);
    mpoint.add(pt2);

    mpoint.removePoint(1);

    Point pt;
    pt = mpoint.getPoint(0);
    assertTrue(pt.getX() == pt0.getX() && pt.getY() == pt0.getY());
    pt = mpoint.getPoint(1);
    assertTrue(pt.getX() == pt2.getX() && pt.getY() == pt2.getY());

    assertTrue(mpoint.getPointCount() == 2);
  }