use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class AbstractGeoreferencedImage method loadAuxXmlFile.
protected void loadAuxXmlFile(final long modifiedTime) {
final Resource resource = getImageResource();
final String extension = resource.getFileNameExtension();
final Resource auxFile = resource.newResourceChangeExtension(extension + ".aux.xml");
if (auxFile.exists() && auxFile.getLastModified() > modifiedTime) {
loadWorldFileX();
final int[] dpi = getDpi();
try {
int srid = 0;
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
final DocumentBuilder builder = factory.newDocumentBuilder();
final InputStream in = auxFile.getInputStream();
try {
final Document doc = builder.parse(in);
final NodeList spatialReferences = doc.getElementsByTagName("SpatialReference");
for (int i = 0; i < spatialReferences.getLength() && srid == 0; i++) {
final Node spatialReference = spatialReferences.item(i);
Element sridElement = DomUtil.getFirstChildElement(spatialReference, "LatestWKID");
if (sridElement == null) {
sridElement = DomUtil.getFirstChildElement(spatialReference, "WKID");
}
if (sridElement != null) {
srid = DomUtil.getInteger(sridElement);
}
}
GeometryFactory geometryFactory = GeometryFactory.floating2d(srid);
if (srid == 0) {
final NodeList srsList = doc.getElementsByTagName("SRS");
for (int i = 0; i < srsList.getLength() && srid == 0; i++) {
final Node srsNode = srsList.item(i);
final String srsWkt = srsNode.getTextContent();
geometryFactory = GeometryFactory.floating2d(srsWkt);
}
}
setGeometryFactory(geometryFactory);
final List<Double> sourceControlPoints = DomUtil.getDoubleList(doc, "SourceGCPs");
final List<Double> targetControlPoints = DomUtil.getDoubleList(doc, "TargetGCPs");
if (sourceControlPoints.size() > 0 && targetControlPoints.size() > 0) {
final List<MappedLocation> tiePoints = new ArrayList<>();
for (int i = 0; i < sourceControlPoints.size() && i < targetControlPoints.size(); i += 2) {
final double imageX = sourceControlPoints.get(i) * dpi[0];
final double imageY = sourceControlPoints.get(i + 1) * dpi[1];
final Point sourcePixel = new PointDoubleXY(imageX, imageY);
final double x = targetControlPoints.get(i);
final double y = targetControlPoints.get(i + 1);
final Point targetPoint = geometryFactory.point(x, y);
final MappedLocation tiePoint = new MappedLocation(sourcePixel, targetPoint);
tiePoints.add(tiePoint);
}
setTiePoints(tiePoints);
}
} finally {
FileUtil.closeSilent(in);
}
} catch (final Throwable e) {
Logs.error(this, "Unable to read: " + auxFile, e);
}
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class ConvexHullTest method testManyIdenticalPoints.
public void testManyIdenticalPoints() throws Exception {
final List<Point> points = new ArrayList<>();
for (int i = 0; i < 99; i++) {
points.add(new PointDoubleXY(0.0, 0));
}
points.add(new PointDoubleXY(1.0, 1));
final Geometry actualGeometry = ConvexHull.convexHull(this.geometryFactory, points);
final Geometry expectedGeometry = this.geometryFactory.geometry("LINESTRING(0 0,1 1)");
assertTrue(expectedGeometry.equals(2, actualGeometry));
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class RandomOffsetLineStringGenerator method generate.
public Geometry generate(final GeometryFactory fact) {
this.pts = new Point[this.numPts];
this.pts[0] = GeometryFactory.DEFAULT_3D.point();
final double ang = Math.PI * Math.random();
this.endPoint = new PointDoubleXY(this.maxSegLen * Math.cos(ang), this.maxSegLen * Math.sin(ang));
this.pts[this.numPts - 1] = this.endPoint;
int interval = this.numPts / 2;
while (interval >= 1) {
newRandomOffsets(interval);
interval /= 2;
}
return fact.lineString(this.pts);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class TestPerfDistanceGeomPair method newCircles.
Geometry[] newCircles(final int nPts) {
final GeometricShapeFactory gsf = new GeometricShapeFactory();
gsf.setCentre(new PointDoubleXY(0, 0));
gsf.setSize(100);
gsf.setNumPoints(nPts);
final Polygon gRect = gsf.newCircle();
gsf.setCentre(new PointDoubleXY(0, this.separationDist));
final Polygon gRect2 = gsf.newCircle();
return new Geometry[] { gRect, gRect2 };
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class TestPerfDistanceLinesPoints method newDiagonalCircles.
Geometry newDiagonalCircles(final double extent, final int nSegs) {
final Polygon[] circles = new Polygon[nSegs];
final double inc = extent / nSegs;
for (int i = 0; i < nSegs; i++) {
final double ord = i * inc;
final Point p = new PointDoubleXY(ord, ord);
final Geometry pt = geomFact.point(p);
circles[i] = (Polygon) pt.buffer(inc / 2);
}
return geomFact.polygonal(circles);
}
Aggregations