use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class Counter method computeBoundaryCoordinates.
private Point[] computeBoundaryCoordinates(final Lineal mLine) {
final List bdyPts = new ArrayList();
this.endpointMap = new TreeMap();
for (int i = 0; i < mLine.getGeometryCount(); i++) {
final LineString line = (LineString) mLine.getGeometry(i);
if (line.getVertexCount() == 0) {
continue;
}
addEndpoint(line.getPoint(0));
addEndpoint(line.getPoint(line.getVertexCount() - 1));
}
for (final Iterator it = this.endpointMap.entrySet().iterator(); it.hasNext(); ) {
final Map.Entry entry = (Map.Entry) it.next();
final Counter counter = (Counter) entry.getValue();
final int valence = counter.count;
if (this.bnRule.isInBoundary(valence)) {
bdyPts.add(entry.getKey());
}
}
return (Point[]) bdyPts.toArray(new Point[0]);
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class NodedSegmentString method addIntersectionNode.
/**
* Adds an intersection node for a given point and segment to this segment string.
* If an intersection already exists for this exact location, the existing
* node will be returned.
*
* @param point the location of the intersection
* @param segmentIndex the index of the segment containing the intersection
* @return the intersection node for the point
*/
public SegmentNode addIntersectionNode(final Point point, final int segmentIndex) {
final double x = point.getX();
final double y = point.getY();
int normalizedSegmentIndex = segmentIndex;
// normalize the intersection point location
final int nextSegIndex = normalizedSegmentIndex + 1;
if (nextSegIndex < size()) {
// The check for point equality is 2D only - Z values are ignored
if (equalsVertex(nextSegIndex, x, y)) {
normalizedSegmentIndex = nextSegIndex;
}
}
/**
* Add the intersection point to edge intersection list.
*/
final SegmentNode ei = this.nodeList.add(x, y, normalizedSegmentIndex);
return ei;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class NodedSegmentString method addIntersection.
/**
* Add an SegmentNode for intersection intIndex.
* An intersection that falls exactly on a vertex
* of the SegmentString is normalized
* to use the higher of the two possible segmentIndexes
*/
public void addIntersection(final LineIntersector li, final int segmentIndex, final int geomIndex, final int intIndex) {
final Point point = li.getIntersection(intIndex);
addIntersection(point, segmentIndex);
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class EsriGeodatabaseXmlRecordWriter method writeDataElement.
private void writeDataElement(final RecordDefinition recordDefinition, final Geometry geometry) {
final String dataElementType;
final FieldDefinition geometryField = recordDefinition.getGeometryField();
boolean hasGeometry = false;
DataType geometryDataType = null;
if (geometryField != null) {
geometryDataType = geometryField.getDataType();
if (this.fieldTypes.getFieldType(geometryDataType) != null) {
hasGeometry = true;
if (geometryDataType.equals(DataTypes.POINT)) {
this.geometryType = GEOMETRY_TYPE_POINT;
} else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
this.geometryType = GEOMETRY_TYPE_MULTI_POINT;
} else if (geometryDataType.equals(DataTypes.LINE_STRING)) {
this.geometryType = GEOMETRY_TYPE_POLYLINE;
} else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
this.geometryType = GEOMETRY_TYPE_POLYLINE;
} else if (geometryDataType.equals(DataTypes.POLYGON)) {
this.geometryType = GEOMETRY_TYPE_POLYGON;
} else {
if (geometry instanceof Point) {
this.geometryType = GEOMETRY_TYPE_POINT;
} else if (geometry instanceof Punctual) {
this.geometryType = GEOMETRY_TYPE_MULTI_POINT;
} else if (geometry instanceof Lineal) {
this.geometryType = GEOMETRY_TYPE_POLYLINE;
} else if (geometry instanceof Polygon) {
this.geometryType = GEOMETRY_TYPE_POLYGON;
} else {
hasGeometry = false;
}
}
}
}
if (hasGeometry) {
dataElementType = DATA_ELEMENT_FEATURE_CLASS;
this.datasetType = DATASET_TYPE_FEATURE_CLASS;
} else {
dataElementType = DATA_ELEMENT_TABLE;
this.datasetType = DATASET_TYPE_TABLE;
}
this.out.startTag(DATA_ELEMENT);
this.out.attribute(XsiConstants.TYPE, dataElementType);
final String path = recordDefinition.getPath();
final String localName = PathUtil.getName(path);
this.out.element(CATALOG_PATH, "/FC=" + localName);
this.out.element(NAME, localName);
this.out.element(METADATA_RETRIEVED, true);
this.out.startTag(METADATA);
this.out.attribute(XsiConstants.TYPE, XML_PROPERTY_SET_TYPE);
this.out.startTag(XML_DOC);
this.out.text("<?xml version=\"1.0\"?>");
this.out.text("<metadata xml:lang=\"en\">");
this.out.text("<Esri>");
this.out.text("<MetaID>{");
this.out.text(UUID.randomUUID().toString().toUpperCase());
this.out.text("}</MetaID>");
this.out.text("<CreaDate>");
final Timestamp date = new Timestamp(System.currentTimeMillis());
this.out.text(Dates.format("yyyyMMdd", date));
this.out.text("</CreaDate>");
this.out.text("<CreaTime>");
this.out.text(Dates.format("HHmmssSS", date));
this.out.text("</CreaTime>");
this.out.text("<SyncOnce>TRUE</SyncOnce>");
this.out.text("</Esri>");
this.out.text("</metadata>");
this.out.endTag(XML_DOC);
this.out.endTag(METADATA);
this.out.element(DATASET_TYPE, this.datasetType);
this.out.element(DSID, this.datasetId++);
this.out.element(VERSIONED, false);
this.out.element(CAN_VERSION, false);
this.out.element(HAS_OID, true);
this.out.element(OBJECT_ID_FIELD_NAME, "OBJECTID");
writeFields(recordDefinition);
this.out.element(CLSID, "{52353152-891A-11D0-BEC6-00805F7C4268}");
this.out.emptyTag(EXTCLSID);
this.out.startTag(RELATIONSHIP_CLASS_NAMES);
this.out.attribute(XsiConstants.TYPE, NAMES_TYPE);
this.out.endTag(RELATIONSHIP_CLASS_NAMES);
this.out.element(ALIAS_NAME, localName);
this.out.emptyTag(MODEL_NAME);
this.out.element(HAS_GLOBAL_ID, false);
this.out.emptyTag(GLOBAL_ID_FIELD_NAME);
this.out.emptyTag(RASTER_FIELD_NAME);
this.out.startTag(EXTENSION_PROPERTIES);
this.out.attribute(XsiConstants.TYPE, PROPERTY_SET_TYPE);
this.out.startTag(PROPERTY_ARRAY);
this.out.attribute(XsiConstants.TYPE, PROPERTY_ARRAY_TYPE);
this.out.endTag(PROPERTY_ARRAY);
this.out.endTag(EXTENSION_PROPERTIES);
this.out.startTag(CONTROLLER_MEMBERSHIPS);
this.out.attribute(XsiConstants.TYPE, CONTROLLER_MEMBERSHIPS_TYPE);
this.out.endTag(CONTROLLER_MEMBERSHIPS);
if (hasGeometry) {
this.out.element(FEATURE_TYPE, FEATURE_TYPE_SIMPLE);
this.out.element(SHAPE_TYPE, this.geometryType);
this.out.element(SHAPE_FIELD_NAME, geometryField.getName());
final GeometryFactory geometryFactory = geometryField.getProperty(FieldProperties.GEOMETRY_FACTORY);
this.out.element(HAS_M, false);
this.out.element(HAS_Z, geometryFactory.hasZ());
this.out.element(HAS_SPATIAL_INDEX, false);
this.out.emptyTag(AREA_FIELD_NAME);
this.out.emptyTag(LENGTH_FIELD_NAME);
writeExtent(geometryFactory);
writeSpatialReference(geometryFactory);
}
this.out.endTag(DATA_ELEMENT);
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class ShapefileGeometryHandler method writePointM.
public void writePointM(final EndianOutput out, final Geometry geometry) {
if (geometry instanceof Point) {
final Point point = (Point) geometry;
if (this.writeLength) {
final int recordLength = 14;
// (BYTES_IN_INT + 3 * BYTES_IN_DOUBLE) / BYTES_IN_SHORT;
out.writeInt(recordLength);
}
out.writeLEInt(ShapefileConstants.POINT_M_SHAPE);
writeXy(out, point);
final double m = point.getM();
if (Double.isNaN(m)) {
out.writeLEDouble(0);
} else {
out.writeLEDouble(m);
}
} else {
throw new IllegalArgumentException("Expecting " + Point.class + " geometry got " + geometry.getClass());
}
}
Aggregations