use of com.revolsys.geometry.cs.projection.CoordinatesOperation in project com.revolsys.open by revolsys.
the class Point method convertCoordinates.
default double[] convertCoordinates(GeometryFactory geometryFactory) {
final GeometryFactory sourceGeometryFactory = getGeometryFactory();
final double[] coordinates = getCoordinates();
if (isEmpty()) {
return coordinates;
} else {
geometryFactory = getNonZeroGeometryFactory(geometryFactory);
double[] targetCoordinates;
final CoordinatesOperation coordinatesOperation = sourceGeometryFactory.getCoordinatesOperation(geometryFactory);
if (coordinatesOperation == null) {
return coordinates;
} else {
final int sourceAxisCount = getAxisCount();
targetCoordinates = new double[sourceAxisCount * getVertexCount()];
coordinatesOperation.perform(sourceAxisCount, coordinates, sourceAxisCount, targetCoordinates);
return targetCoordinates;
}
}
}
use of com.revolsys.geometry.cs.projection.CoordinatesOperation in project com.revolsys.open by revolsys.
the class Geometry method forEachVertex.
default void forEachVertex(final GeometryFactory geometryFactory, final int axisCount, final Consumer<double[]> action) {
if (!isEmpty()) {
final double[] coordinates = new double[axisCount];
Arrays.fill(coordinates, Double.NaN);
if (isProjectionRequired(geometryFactory)) {
final CoordinatesOperation coordinatesOperation = getCoordinatesOperation(geometryFactory);
forEachVertex(coordinatesOperation, coordinates, action);
} else {
forEachVertex(coordinates, action);
}
}
}
use of com.revolsys.geometry.cs.projection.CoordinatesOperation in project com.revolsys.open by revolsys.
the class ProjectionImageFilter method filterPixels.
@Override
protected int[] filterPixels(final int imageWidth, final int imageHeight, final int[] inPixels, final Rectangle transformedSpace) {
final int[] outPixels = new int[transformedSpace.width * transformedSpace.height];
final double minX = this.sourceBoundingBox.getMinX();
final double minY = this.sourceBoundingBox.getMinY();
final double width = this.sourceBoundingBox.getWidth();
final double height = this.sourceBoundingBox.getHeight();
final double pixelWidth = width / imageWidth;
final double pixelHeight = height / imageHeight;
final double newMinX = this.destBoundingBox.getMinX();
final double newMaxY = this.destBoundingBox.getMaxY();
final int newImageWidth = transformedSpace.width;
final int newImageHeight = transformedSpace.height;
final GeometryFactory sourceGeometryFactory = this.sourceBoundingBox.getGeometryFactory();
final GeometryFactory destGeometryFactory = this.destBoundingBox.getGeometryFactory();
final CoordinatesOperation operation = destGeometryFactory.getCoordinatesOperation(sourceGeometryFactory);
if (operation == null) {
return inPixels;
}
final double[] source = new double[2];
final double[] dest = new double[2];
for (int i = 0; i < newImageWidth; i++) {
final double newImageX = newMinX + i * this.destPixelSize;
dest[0] = newImageX;
for (int j = 0; j < newImageHeight; j++) {
final double newImageY = newMaxY - j * this.destPixelSize;
dest[1] = newImageY;
operation.perform(2, dest, 2, source);
final double imageX = source[0];
final double imageY = source[1];
final int imageI = (int) ((imageX - minX) / pixelWidth);
final int imageJ = imageHeight - (int) ((imageY - minY) / pixelHeight);
if (imageI > -1 && imageI < imageWidth) {
if (imageJ > -1 && imageJ < imageHeight) {
final int rgb = inPixels[imageJ * imageWidth + imageI];
if (rgb != -1) {
outPixels[j * newImageWidth + i] = rgb;
// // TODO better interpolation
}
}
}
}
}
return outPixels;
}
use of com.revolsys.geometry.cs.projection.CoordinatesOperation in project com.revolsys.open by revolsys.
the class Point method convertPoint2d.
default Point convertPoint2d(final GeometryFactory geometryFactory) {
if (isEmpty()) {
return this;
} else {
final CoordinatesOperation coordinatesOperation = getGeometryFactory().getCoordinatesOperation(geometryFactory);
if (coordinatesOperation == null) {
return this;
} else {
final double sourceX = getX();
final double sourceY = getY();
final double[] targetCoordinates = new double[] { sourceX, sourceY };
coordinatesOperation.perform(2, targetCoordinates, 2, targetCoordinates);
final double targetX = targetCoordinates[X];
final double targetY = targetCoordinates[Y];
return new PointDoubleXY(targetX, targetY);
}
}
}
use of com.revolsys.geometry.cs.projection.CoordinatesOperation in project com.revolsys.open by revolsys.
the class LineString method convertCoordinates.
default double[] convertCoordinates(GeometryFactory geometryFactory, final int axisCount) {
final GeometryFactory sourceGeometryFactory = getGeometryFactory();
final double[] coordinates = getCoordinates(axisCount);
if (isEmpty()) {
return coordinates;
} else {
geometryFactory = getNonZeroGeometryFactory(geometryFactory);
double[] targetCoordinates;
final CoordinatesOperation coordinatesOperation = sourceGeometryFactory.getCoordinatesOperation(geometryFactory);
if (coordinatesOperation == null) {
return coordinates;
} else {
final int sourceAxisCount = getAxisCount();
targetCoordinates = new double[sourceAxisCount * getVertexCount()];
coordinatesOperation.perform(sourceAxisCount, coordinates, sourceAxisCount, targetCoordinates);
return targetCoordinates;
}
}
}
Aggregations