use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.
the class GridInterpolation method interpolateToLineString.
private LineString interpolateToLineString(Arc arc) {
// arc segments to process
Deque<ArcSegment> toProcess = new LinkedList<>();
// start with full arc as segment
toProcess.addFirst(new ArcGridSegment(arc, moveAllToGrid, gridSize));
// list to collect atomic parts
List<ArcSegment> parts = new LinkedList<>();
// for every segment to process...
while (!toProcess.isEmpty()) {
ArcSegment segment = toProcess.pop();
if (segment.isAtomic()) {
// segment cannot be split
// -> use for result
parts.add(segment);
} else {
// otherwise split the segment in two and handle the parts
toProcess.addFirst(segment.getSecondPart());
toProcess.addFirst(segment.getFirstPart());
}
}
// combine the segments to a single LineString
List<Coordinate> coords = new ArrayList<>();
for (int i = 0; i < parts.size(); i++) {
ArcSegment part = parts.get(i);
if (i == 0) {
coords.add(part.getStartPoint());
}
Coordinate middle = part.getMiddlePoint();
if (middle != null) {
// should actually not occur
InterpolationUtil.addIfDifferent(coords, middle);
}
InterpolationUtil.addIfDifferent(coords, part.getEndPoint());
}
return createLineString(coords.toArray(new Coordinate[coords.size()]), arc);
}
use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.
the class ArcByCenterPointImpl method toArcByPoints.
/**
* {@inheritDoc}
*
* @author Arun Verma
*/
@Override
public ArcByPoints toArcByPoints() {
if (pointsRepresentation == null) {
Angle middleAngle = Angle.fromRadians(startAngle.getRadians() + 0.5 * getAngleBetween().getRadians());
// getting start coordinate
Coordinate startPoint = getPointAtAngle(startAngle);
// getting end coordinate
Coordinate endPoint = getPointAtAngle(endAngle);
// will generate middle coordinate to use already coded arc
// interpolation
Coordinate middlePoint = getPointAtAngle(middleAngle);
pointsRepresentation = new ArcByPointsImpl(startPoint, middlePoint, endPoint);
}
return pointsRepresentation;
}
use of org.locationtech.jts.geom.Coordinate in project sldeditor by robward-scisys.
the class ExampleLineImpl method getLine.
/*
* (non-Javadoc)
*
* @see com.sldeditor.datasource.impl.ExampleLineInterface#getLine()
*/
@Override
public LineString getLine() {
if (line == null) {
// CHECKSTYLE:OFF
double[][] rawLocations = new double[][] { { -123.167725, 48.502048 }, { -123.464355, 48.297812 }, { -124.738770, 48.603858 }, { -125.189209, 48.828566 }, { -125.112305, 48.951366 }, { -125.507812, 48.929718 }, { -125.870361, 49.145784 }, { -126.035156, 49.167339 }, { -126.112061, 49.253465 }, { -126.243896, 49.282140 }, { -126.287842, 49.360912 }, { -126.397705, 49.410973 }, { -126.573486, 49.375220 }, { -126.584473, 49.560852 }, { -126.815186, 49.610710 }, { -127.012939, 49.745781 }, { -126.947021, 49.788357 }, { -127.166748, 49.852152 }, { -127.518311, 50.113533 }, { -127.814941, 50.078295 }, { -127.957764, 50.120578 }, { -127.825928, 50.254230 }, { -128.012695, 50.331436 }, { -127.946777, 50.450509 }, { -128.122559, 50.457504 }, { -128.364258, 50.652943 }, { -128.342285, 50.792047 }, { -128.100586, 50.882243 }, { -127.858887, 50.944584 }, { -127.518311, 50.798991 }, { -127.221680, 50.639010 } };
// CHECKSTYLE:ON
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Coordinate[] coords = new Coordinate[rawLocations.length];
int index = 0;
for (double[] point : rawLocations) {
Coordinate c = new Coordinate(point[0], point[1]);
coords[index] = c;
index++;
}
line = geometryFactory.createLineString(coords);
}
return line;
}
use of org.locationtech.jts.geom.Coordinate in project sldeditor by robward-scisys.
the class SLDEditorBufferedImageLegendGraphicBuilder method getSampleShape.
/**
* Returns a <code>java.awt.Shape</code> appropiate to render a legend graphic given the
* symbolizer type and the legend dimensions.
*
* @param symbolizer the Symbolizer for whose type a sample shape will be created
* @param legendWidth the requested width, in output units, of the legend graphic
* @param legendHeight the requested height, in output units, of the legend graphic
* @return an appropiate Line2D, Rectangle2D or LiteShape(Point) for the symbolizer, wether it
* is a LineSymbolizer, a PolygonSymbolizer, or a Point ot Text Symbolizer
* @throws IllegalArgumentException if an unknown symbolizer impl was passed in.
*/
private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth, int legendHeight) {
LiteShape2 sampleShape;
final float hpad = (legendWidth * LegendUtils.hpaddingFactor);
final float vpad = (legendHeight * LegendUtils.vpaddingFactor);
if (symbolizer instanceof LineSymbolizer) {
Coordinate[] coords = { new Coordinate(hpad, legendHeight - vpad - 1), new Coordinate(legendWidth - hpad - 1, vpad) };
LineString geom = geomFac.createLineString(coords);
try {
this.sampleLine = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleLine = null;
}
sampleShape = this.sampleLine;
} else if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof RasterSymbolizer)) {
final float w = legendWidth - (2 * hpad) - 1;
final float h = legendHeight - (2 * vpad) - 1;
Coordinate[] coords = { new Coordinate(hpad, vpad), new Coordinate(hpad, vpad + h), new Coordinate(hpad + w, vpad + h), new Coordinate(hpad + w, vpad), new Coordinate(hpad, vpad) };
LinearRing shell = geomFac.createLinearRing(coords);
Polygon geom = geomFac.createPolygon(shell, null);
try {
this.sampleRect = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleRect = null;
}
sampleShape = this.sampleRect;
} else if (symbolizer instanceof PointSymbolizer || symbolizer instanceof TextSymbolizer) {
Coordinate coord = new Coordinate(legendWidth / 2, legendHeight / 2);
try {
this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
} catch (Exception e) {
this.samplePoint = null;
}
sampleShape = this.samplePoint;
} else {
throw new IllegalArgumentException("Unknown symbolizer: " + symbolizer);
}
return sampleShape;
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class JTSGeometryWrapperTest method testComputeJTSPeerWithGeometry.
@Test
public void testComputeJTSPeerWithGeometry() {
GeometryFactory fac = new GeometryFactory();
Geometry toWrap = fac.createPoint(new Coordinate(0, 0));
toTest = new JTSGeometryWrapper(toWrap);
assertEquals(toWrap, toTest.computeJTSPeer());
}
Aggregations