private Point ellipsePtFromAngle(Point center, double rh, double rv, double angle) { double x = center.getX(); double y = center.getY(); double c = Math.cos(angle); double s = Math.sin(angle); double ta = s / c; double tt = ta * (rh / rv); double d = 1.0 / Math.sqrt(1.0 + Math.pow(tt, 2)); double ex = x + Math.copySign(rh * d, c); double ey = y + Math.copySign(rv * tt * d, s); return new Point(ex, ey); }
public SearchResult(Double latitude, Double longitude) { super(); this.type = RESULT_ADDRESS; Point point = getPoint(latitude, longitude); this.title = point.toString(); this.coordinates = point; }
private static Point _rotate(Point center, Point inPt, double ra) { double x = inPt.getX(); double y = inPt.getY(); double cx = center.getX(); double cy = center.getY(); double cosra = Math.cos(ra); double sinra = Math.sin(ra); double rx = cx + cosra * (x - cx) - sinra * (y - cy); double ry = cy + sinra * (x - cx) + cosra * (y - cy); Point rPt = new Point(rx, ry); return rPt; }
/** Sets the Point to a default, non-empty state. */ void _setToDefault() { resizeAttributes(m_description._getTotalComponents()); Point.attributeCopy( m_description._getDefaultPointAttributes(), m_attributes, m_description._getTotalComponents()); m_attributes[0] = NumberUtils.NaN(); m_attributes[1] = NumberUtils.NaN(); }
/** * Returns TRUE when this geometry has exactly same type, properties, and coordinates as the other * geometry. */ @Override public boolean equals(Object _other) { if (_other == this) return true; if (!(_other instanceof Point)) return false; Point otherPt = (Point) _other; if (m_description != otherPt.m_description) return false; if (isEmptyImpl()) if (otherPt.isEmptyImpl()) return true; else return false; for (int i = 0, n = m_description._getTotalComponents(); i < n; i++) if (m_attributes[i] != otherPt.m_attributes[i]) return false; return true; }
@Override public void insertAttributes(int start, Point pt, int semantics, int validSize) { if (m_bReadonly) throw new GeometryException("invalid_call"); int comp = VertexDescription.getComponentCount(semantics); System.arraycopy(m_buffer, start, m_buffer, start + comp, validSize - start); for (int c = 0; c < comp; c++) { m_buffer[start + c] = (int) pt.getAttributeAsDbl(semantics, c); } }
@Override public void copyTo(Geometry dst) { if (dst.getType() != Type.Point) throw new IllegalArgumentException(); Point pointDst = (Point) dst; dst._touch(); if (m_attributes == null) { pointDst.setEmpty(); pointDst.m_attributes = null; pointDst.assignVertexDescription(m_description); } else { pointDst.assignVertexDescription(m_description); pointDst.resizeAttributes(m_description._getTotalComponents()); attributeCopy(m_attributes, pointDst.m_attributes, m_description._getTotalComponents()); } }
public void writeToParcel(Parcel dest, int flags) { dest.writeInt(type); dest.writeString(title); dest.writeDouble(coordinates.getX()); dest.writeDouble(coordinates.getY()); }
public SearchResult(Point coordinates) { super(); this.type = RESULT_COORDINATES; this.title = coordinates.toString(); this.coordinates = coordinates; }
@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); }
@Test public static void testCopy() { 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); MultiPoint mpCopy = (MultiPoint) mpoint.copy(); assertTrue(mpCopy.equals(mpoint)); Point pt; pt = mpCopy.getPoint(0); assertTrue(pt.getX() == pt0.getX() && pt.getY() == pt0.getY()); pt = mpCopy.getPoint(1); assertTrue(pt.getX() == pt2.getX() && pt.getY() == pt2.getY()); assertTrue(mpCopy.getPointCount() == 2); }