本文整理汇总了Java中com.vividsolutions.jts.geom.impl.CoordinateArraySequence类的典型用法代码示例。如果您正苦于以下问题:Java CoordinateArraySequence类的具体用法?Java CoordinateArraySequence怎么用?Java CoordinateArraySequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateArraySequence类属于com.vividsolutions.jts.geom.impl包,在下文中一共展示了CoordinateArraySequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: homothetie
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
public static Polygon homothetie(Polygon geom, double x0, double y0,
double scale) {
GeometryFactory gf = new GeometryFactory();
// le contour externe
Coordinate[] coord = geom.getExteriorRing().getCoordinates();
Coordinate[] coord_ = new Coordinate[coord.length];
for (int i = 0; i < coord.length; i++) {
coord_[i] = new Coordinate(x0 + scale * (coord[i].x - x0),
y0 + scale * (coord[i].y - y0));
}
LinearRing lr = gf.createLinearRing(new CoordinateArraySequence(coord_));
// les trous
LinearRing[] trous = new LinearRing[geom.getNumInteriorRing()];
for (int j = 0; j < geom.getNumInteriorRing(); j++) {
Coordinate[] hole_coord = geom.getInteriorRingN(j).getCoordinates();
Coordinate[] hole_coord_ = new Coordinate[hole_coord.length];
for (int i = 0; i < hole_coord.length; i++) {
hole_coord_[i] = new Coordinate(x0 + scale * (hole_coord[i].x - x0),
y0 + scale * (hole_coord[i].y - y0));
}
trous[j] = gf.createLinearRing(new CoordinateArraySequence(hole_coord_));
}
return gf.createPolygon(lr, trous);
}
示例2: createCompoundLineString
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* <p>createCompoundLineString.</p>
*
* @param factory a {@link com.vividsolutions.jts.geom.GeometryFactory} object.
* @param segments a {@link com.vividsolutions.jts.geom.LineString} object.
* @return a {@link nl.pdok.gml3.impl.geometry.extended.CompoundLineString} object.
*/
public static CompoundLineString createCompoundLineString(GeometryFactory factory,
LineString... segments) {
List<Coordinate> coordinates = new ArrayList<Coordinate>();
for(int i=0; i<segments.length; i++) {
LineString segment = segments[i];
Coordinate[] coordinateArray = segment.getCoordinates();
if(i != segments.length-1) {
int lengtWithoutLastElement = coordinateArray.length-1;
Coordinate[] coordinateArray2 = new Coordinate[lengtWithoutLastElement];
System.arraycopy(coordinateArray, 0, coordinateArray2, 0, lengtWithoutLastElement);
coordinates.addAll(Arrays.asList(coordinateArray2));
}
else {
coordinates.addAll(Arrays.asList(coordinateArray));
}
}
CoordinateSequence coordinateSequence = new CoordinateArraySequence(
coordinates.toArray(new Coordinate[]{}));
CompoundLineString curveLineString = new CompoundLineString(coordinateSequence, factory,
segments);
return curveLineString;
}
示例3: translateLinearRingType
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
private LinearRing translateLinearRingType(LinearRingType ring) throws GeometryException {
if (ring.getPosList() == null) {
throw new DeprecatedGeometrySpecificationException("Geen post list voor ring gespecificeerd");
}
CoordinateArraySequence sequence = gmlToPointConvertor.translateOrdinates(ring.getPosList());
int length = sequence.size();
Coordinate firstCoordinate = length == 0 ? null : sequence.getCoordinate(0);
if (length < NUMBER_OF_COORDINATES_NEEDED_FOR_RING) {
throw new InvalidGeometryException(GeometryValidationErrorType.TOO_FEW_POINTS, firstCoordinate);
}
if (!isClosed(sequence)) {
throw new InvalidGeometryException(GeometryValidationErrorType.RING_NOT_CLOSED, firstCoordinate);
}
return geometryFactory.createLinearRing(sequence);
}
示例4: getCoordinatesForArc
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
private CoordinateArraySequence getCoordinatesForArc(ArcType arc) throws GeometryException {
if(arc.getPosList() != null) {
return gmlToPointConvertor.translateOrdinates(arc.getPosList());
}
else if(arc.getPosOrPointPropertyOrPointRep() != null &&
arc.getPosOrPointPropertyOrPointRep().size() > 0) {
List<Double> values = new ArrayList<Double>();
Iterator<JAXBElement<?>> iterator = arc.getPosOrPointPropertyOrPointRep().iterator();
while(iterator.hasNext()) {
Object value = iterator.next().getValue();
if(value instanceof DirectPositionType) {
DirectPositionType position = (DirectPositionType) value;
values.addAll(position.getValue());
}
else {
throw new DeprecatedGeometrySpecificationException(
"Geen poslist voor arc binnen curve gespecificeerd");
}
}
return gmlToPointConvertor.translateOrdinates(values, 2); // could be 3 too?
}
else {
throw new DeprecatedGeometrySpecificationException("Geen poslist voor arc binnen curve gespecificeerd");
}
}
示例5: translateOrdinates
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* <p>translateOrdinates.</p>
*
* @param coordinates a {@link java.util.List} object.
* @param dimension a {@link int}.
* @return a {@link com.vividsolutions.jts.geom.impl.CoordinateArraySequence} object.
* @throws nl.pdok.gml3.exceptions.InvalidGeometryException if any.
* @throws nl.pdok.gml3.exceptions.CoordinateMaxScaleExceededException if any.
*/
public CoordinateArraySequence translateOrdinates(List<Double> coordinates, int dimension)
throws InvalidGeometryException, CoordinateMaxScaleExceededException {
if (coordinates == null || coordinates.size() < dimension) {
throw new InvalidGeometryException(GeometryValidationErrorType.EMPTY_GEOMETRY, null);
}
if(coordinates.size()%dimension != 0) {
throw new InvalidGeometryException(GeometryValidationErrorType.INVALID_COORDINATE, null);
}
CoordinateArraySequence sequence = new CoordinateArraySequence(coordinates.size() / dimension);
int i = 0;
for (Double ordinate : coordinates) {
BigDecimal bd = new BigDecimal(ordinate);
int ordinateIndex = i % dimension;
int index = (i / dimension);
sequence.setOrdinate(index, ordinateIndex, bd.doubleValue());
i++;
}
return sequence;
}
示例6: convertPoint
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* <p>convertPoint.</p>
*
* @param point a {@link net.opengis.gml.v_3_1_1.PointType} object.
* @return a {@link com.vividsolutions.jts.geom.Point} object.
* @throws nl.pdok.gml3.exceptions.GeometryException if any.
*/
public Point convertPoint(PointType point) throws GeometryException {
DirectPositionType pos = point.getPos();
int dimension = pos.getSrsDimension() != null ? pos.getSrsDimension().intValue() : pos.getValue().size();
if(point.getPos() == null) {
throw new DeprecatedGeometrySpecificationException(
"Geen post list voor ring gespecificeerd");
}
List<Double> values = pos.getValue();
if(values.size() != dimension) {
throw new InvalidGeometryException(GeometryValidationErrorType.POINT_INVALID_NUMBER_OF_ORDINATES, null);
}
CoordinateArraySequence sequence = translateOrdinates(values, dimension);
return geometryFactory.createPoint(sequence);
}
示例7: translateOrdinates
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* <p>translateOrdinates.</p>
*
* @param ordinates a {@link java.util.List} object.
* @param dimension a {@link int}.
* @return a {@link com.vividsolutions.jts.geom.impl.CoordinateArraySequence} object.
* @throws nl.pdok.gml3.exceptions.InvalidGeometryException if any.
* @throws nl.pdok.gml3.exceptions.CoordinateMaxScaleExceededException if any.
*/
public CoordinateArraySequence translateOrdinates(List<Double> ordinates, int dimension)
throws InvalidGeometryException, CoordinateMaxScaleExceededException {
if (ordinates == null || ordinates.size() < dimension) {
throw new InvalidGeometryException(GeometryValidationErrorType.EMPTY_GEOMETRY, null);
}
if (ordinates.size()%dimension != 0) {
throw new InvalidGeometryException(GeometryValidationErrorType.INVALID_COORDINATE, createCoordinateFromFirstTwoOrdinates(ordinates));
}
CoordinateArraySequence sequence = new CoordinateArraySequence(ordinates.size() / dimension);
int i = 0;
for (Double ordinate : ordinates) {
BigDecimal bd = new BigDecimal(ordinate);
int ordinateIndex = i % dimension;
int index = (i / dimension);
sequence.setOrdinate(index, ordinateIndex, bd.doubleValue());
i++;
}
return sequence;
}
示例8: convertPoint
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* <p>convertPoint.</p>
*
* @param point a {@link net.opengis.gml.v_3_2_1.PointType} object.
* @return a {@link com.vividsolutions.jts.geom.Point} object.
* @throws nl.pdok.gml3.exceptions.GeometryException if any.
*/
public Point convertPoint(PointType point) throws GeometryException {
DirectPositionType pos = point.getPos();
List<Double> values = pos.getValue();
int dimension = pos.getSrsDimension() != null ? pos.getSrsDimension().intValue() : values.size();
if (point.getPos() == null) {
throw new DeprecatedGeometrySpecificationException(
"Geen post list voor ring gespecificeerd");
}
if (values.size() != dimension) {
throw new InvalidGeometryException(GeometryValidationErrorType.POINT_INVALID_NUMBER_OF_ORDINATES, null);
}
CoordinateArraySequence sequence = translateOrdinates(values, dimension);
return geometryFactory.createPoint(sequence);
}
示例9: translateLinearRingType
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
private LinearRing translateLinearRingType(LinearRingType ring) throws GeometryException {
if (ring.getPosList() == null) {
throw new DeprecatedGeometrySpecificationException("Geen post list voor ring gespecificeerd");
}
CoordinateArraySequence sequence = gmlToPointConvertor.translateOrdinates(ring.getPosList());
int length = sequence.size();
Coordinate firstCoordinate = length == 0 ? null : sequence.getCoordinate(0);
if (length < NUMBER_OF_COORDINATES_NEEDED_FOR_RING) {
throw new InvalidGeometryException(GeometryValidationErrorType.TOO_FEW_POINTS, firstCoordinate);
}
if (!isClosed(sequence)) {
throw new InvalidGeometryException(GeometryValidationErrorType.RING_NOT_CLOSED, firstCoordinate);
}
return geometryFactory.createLinearRing(sequence);
}
示例10: calculate
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
public double calculate(Polygon polygon, Coordinate coordinate, double precisionKilometers, GeometryFactory geometryFactory) {
Point point = new Point(new CoordinateArraySequence(new Coordinate[]{coordinate}), geometryFactory);
if (polygon.contains(point)) {
// todo distance to border? well if that should be the case then factor this method out of this class!
return 0;
}
double smallestDistance = Double.MAX_VALUE;
Coordinate[] coordinates = polygon.getCoordinates();
for (int i = 1; i < coordinates.length; i++) {
for (Coordinate interpolated : new LineInterpolation().interpolate(precisionKilometers, coordinates[i - 1], coordinates[i])) {
double distance = calculate(interpolated, coordinate);
if (distance < smallestDistance) {
smallestDistance = distance;
}
}
}
return smallestDistance;
}
示例11: lngLatToMeters
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* Converts geometry from lat/lon (EPSG:4326)) to Spherical Mercator
* (EPSG:3857)
*
* @param geometry the geometry to convert
* @return the geometry transformed to EPSG:3857
*/
public Geometry lngLatToMeters(Geometry geometry) {
GeometryTransformer transformer = new GeometryTransformer() {
@Override
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) {
Coordinate[] newCoords = new Coordinate[coords.size()];
for (int i = 0; i < coords.size(); ++i) {
Coordinate coord = coords.getCoordinate(i);
newCoords[i] = lngLatToMeters(coord);
}
return new CoordinateArraySequence(newCoords);
}
};
Geometry result = transformer.transform(geometry);
return result;
}
示例12: metersToLngLat
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* Converts geometry from Spherical Mercator
* (EPSG:3857) to lat/lon (EPSG:4326))
*
* @param geometry the geometry to convert
* @return the geometry transformed to EPSG:4326
*/
public Geometry metersToLngLat(Geometry geometry) {
GeometryTransformer transformer = new GeometryTransformer() {
@Override
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) {
Coordinate[] newCoords = new Coordinate[coords.size()];
for (int i = 0; i < coords.size(); ++i) {
Coordinate coord = coords.getCoordinate(i);
newCoords[i] = metersToLngLat(coord);
}
return new CoordinateArraySequence(newCoords);
}
};
Geometry result = transformer.transform(geometry);
return result;
}
示例13: transformIntoPointGeometryCollection
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* Transform into GeometryCollection.
*
* @param geom input geometry
* @return a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[]{coord[i]};
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, geom.getFactory());
}
return new GeometryCollection(geometries, geom.getFactory());
}
示例14: transformIntoPointGeometryCollection
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* Transform into GeometryCollection.
*
* @param geom
* input geometry
* @return
* a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0 ; i < coord.length ; i++) {
Coordinate[] c = new Coordinate[] { coord[i] };
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, geom.getFactory());
}
return new GeometryCollection(geometries, geom.getFactory());
}
示例15: checkRobustInCircle
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; //导入依赖的package包/类
/**
* Checks if the computed value for isInCircle is correct, using
* double-double precision arithmetic.
*
* @param a a vertex of the triangle
* @param b a vertex of the triangle
* @param c a vertex of the triangle
* @param p the point to test
*/
private static void checkRobustInCircle(Coordinate a, Coordinate b, Coordinate c,
Coordinate p) {
boolean nonRobustInCircle = isInCircleNonRobust(a, b, c, p);
boolean isInCircleDD = TrianglePredicate.isInCircleDDSlow(a, b, c, p);
boolean isInCircleCC = TrianglePredicate.isInCircleCC(a, b, c, p);
Coordinate circumCentre = Triangle.circumcentre(a, b, c);
System.out.println("p radius diff a = "
+ Math.abs(p.distance(circumCentre) - a.distance(circumCentre))
/ a.distance(circumCentre));
if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC) {
System.out.println("inCircle robustness failure (double result = "
+ nonRobustInCircle
+ ", DD result = " + isInCircleDD
+ ", CC result = " + isInCircleCC + ")");
System.out.println(WKTWriter.toLineString(new CoordinateArraySequence(
new Coordinate[] { a, b, c, p })));
System.out.println("Circumcentre = " + WKTWriter.toPoint(circumCentre)
+ " radius = " + a.distance(circumCentre));
System.out.println("p radius diff a = "
+ Math.abs(p.distance(circumCentre) / a.distance(circumCentre) - 1));
System.out.println("p radius diff b = "
+ Math.abs(p.distance(circumCentre) / b.distance(circumCentre) - 1));
System.out.println("p radius diff c = "
+ Math.abs(p.distance(circumCentre) / c.distance(circumCentre) - 1));
System.out.println();
}
}