public CoordinateSequence getCoordinateSequence() { return point.getCoordinateSequence(); }
public Object getProperty(Object object, QName name) throws Exception { if (KML.coordinates.getLocalPart().equals(name.getLocalPart())) { Point p = (Point) object; return p.getCoordinateSequence(); } return null; } }
/** * Used with ELEM_INFO <code>( 1, 1, 1)</code> * * @param list List to add coordiantes to * @param point Point to be encoded */ private static void addCoordinates(List list, Point point) { addCoordinates(list, point.getCoordinateSequence()); }
Map<String, Object> createPoint(Point point) { LinkedHashMap obj = new LinkedHashMap(); obj.put("type", "Point"); obj.put("coordinates", new CoordinateSequenceEncoder(point.getCoordinateSequence(), scale)); return obj; }
public Object getProperty(Object object, QName name) { // hack for xlink stuff Geometry geometry = (Geometry) object; if (geometry.isEmpty()) { return null; } if ("pos".equals(name.getLocalPart())) { Point point = (Point) object; return point.getCoordinateSequence(); } return null; } }
private void writePoint(Point pt, OutStream os) throws IOException { if (pt.getCoordinateSequence().size() == 0) throw new IllegalArgumentException("Empty Points cannot be represented in WKB"); writeByteOrder(os); writeGeometryType(DB2WKBConstants.wkbPoint2D, os); writeCoordinateSequence(pt.getCoordinateSequence(), false, os); }
public void write(ByteBuffer buffer, Object geometry) { Point point = (Point) geometry; Coordinate c = point.getCoordinate(); buffer.putDouble(c.x); buffer.putDouble(c.y); if (shapeType == ShapeType.POINTZ) { if (Double.isNaN(c.z)) { // nan means not defined buffer.putDouble(0.0); } else { buffer.putDouble(c.z); } } if ((shapeType == ShapeType.POINTZ) || (shapeType == ShapeType.POINTM)) { double m = point.getCoordinateSequence().getM(0); buffer.putDouble(!Double.isNaN(m) ? m : 0.0); // M } } }
private static final Geometry cloneGeometry(Point geom, int dimension) { return geomFac.createPoint( new LiteCoordinateSequence(geom.getCoordinateSequence(), dimension)); }
@Override public void encode(Point geometry, AttributesImpl atts, GMLWriter handler) throws Exception { handler.startElement(point, atts); handler.coordinates(geometry.getCoordinateSequence()); handler.endElement(point); } }
@Override public void reset(double x, double y) { assert ! isEmpty(); CoordinateSequence cSeq = pointGeom.getCoordinateSequence(); cSeq.setOrdinate(0, CoordinateSequence.X, x); cSeq.setOrdinate(0, CoordinateSequence.Y, y); }
List toList(GeometryCollection mgeom) { ArrayList list = new ArrayList(mgeom.getNumGeometries()); for (int i = 0; i < mgeom.getNumGeometries(); i++) { Geometry g = mgeom.getGeometryN(i); if (g instanceof Polygon) { list.add(toList((Polygon) g)); } else if (g instanceof LineString) { list.add( new CoordinateSequenceEncoder( ((LineString) g).getCoordinateSequence(), scale)); } else if (g instanceof Point) { list.add(new CoordinateSequenceEncoder(((Point) g).getCoordinateSequence(), scale)); } } return list; }
/** * @param point * @throws TransformException */ public Point transformPoint(Point point, GeometryFactory gf) throws TransformException { // if required, init csTransformer using geometry's CSFactory init(gf); CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); Point transformed = gf.createPoint(cs); transformed.setUserData(point.getUserData()); return transformed; }
@Override public void encode(Point geometry, AttributesImpl atts, GMLWriter handler, String gmlId) throws Exception { atts = cloneWithGmlId(atts, gmlId); handler.startElement(point, atts); handler.startElement(pos, null); handler.position(geometry.getCoordinateSequence()); handler.endElement(pos); handler.endElement(point); } }
public void testEncode2D() throws Exception { Point point = GML3MockData.pointLite2D(); CoordinateSequence seq = point.getCoordinateSequence(); Document doc = encode(seq, GML.pos); checkPosOrdinates(doc, 2); }
public void testEncode3D() throws Exception { Point point = GML3MockData.pointLite3D(); CoordinateSequence seq = point.getCoordinateSequence(); Document doc = encode(seq, GML.pos); checkPosOrdinates(doc, 3); }
@Test public void testDecimate3DPoint() throws Exception { Point p = gf.createPoint(csf.create(new double[] {0, 1, 2}, 3)); Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8); d.decimateTransformGeneralize(p, identity); assertEquals(1, p.getNumPoints()); assertEquals(2, p.getCoordinateSequence().getDimension()); }
/** Tests encoding for X, Y, M ordinates number */ @Test public void testEncodeXYM() throws Exception { GeometryFactory gf = new GeometryFactory(); Point pointM = gf.createPoint(new CoordinateXYM(1, 1, 4)); CoordinateSequence seq = pointM.getCoordinateSequence(); Document doc = encode(seq, GML.pos); checkPosOrdinates(doc, 4); }
/** Tests encoding for X, Y, Z, M ordinates number */ @Test public void testEncodeZM() throws Exception { GeometryFactory gf = new GeometryFactory(); Point pointM = gf.createPoint(new CoordinateXYZM(1, 1, 2, 4)); CoordinateSequence seq = pointM.getCoordinateSequence(); Document doc = encode(seq, GML.pos); checkPosOrdinates(doc, 4); } }
@Test public void multiPointZ() throws Exception { double[] ords = {1, 2, 3, 4, 5, 6}; MultiPoint mp = builder.multiPointZ(ords[0], ords[1], ords[2], ords[3], ords[4], ords[5]); assertEquals(2, mp.getNumGeometries()); Point p = (Point) mp.getGeometryN(0); assertEquals(3, p.getCoordinateSequence().getDimension()); }
@Test public void multiPoint() throws Exception { double[] ords = {1, 2, 3, 4}; MultiPoint mp = builder.multiPoint(ords[0], ords[1], ords[2], ords[3]); assertEquals(2, mp.getNumGeometries()); Point p = (Point) mp.getGeometryN(0); assertEquals(2, p.getCoordinateSequence().getDimension()); }