本文整理匯總了Java中com.vividsolutions.jts.geom.GeometryFactory.createLinearRing方法的典型用法代碼示例。如果您正苦於以下問題:Java GeometryFactory.createLinearRing方法的具體用法?Java GeometryFactory.createLinearRing怎麽用?Java GeometryFactory.createLinearRing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.createLinearRing方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ringFromSegments
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
private static LinearRing ringFromSegments(List<LineSegment> segments) {
GeometryFactory factory = new GeometryFactory();
int nSegs = segments.size();
if (nSegs < 3) {
return null;
}
int len = segments.size() + 1;
CoordinateSequence seq = factory.getCoordinateSequenceFactory().create(
len, 2);
int i = 0;
for (LineSegment line : segments) {
seq.setOrdinate(i, 0, line.p0.x);
seq.setOrdinate(i, 1, line.p0.y);
i++;
}
seq.setOrdinate(i, 0, segments.get(0).p0.x);
seq.setOrdinate(i, 1, segments.get(0).p0.y);
return factory.createLinearRing(seq);
}
示例2: edit
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public final Geometry edit(Geometry geometry, GeometryFactory factory) {
if (geometry instanceof LinearRing) {
return factory.createLinearRing(this.edit(geometry.getCoordinates(),
geometry));
}
if (geometry instanceof LineString) {
return factory.createLineString(this.edit(geometry.getCoordinates(),
geometry));
}
if (geometry instanceof Point) {
Coordinate[] newCoordinates = this.edit(geometry.getCoordinates(),
geometry);
return factory.createPoint((newCoordinates.length > 0)
? newCoordinates[0] : null);
}
return geometry;
}
示例3: homothetie
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的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);
}
示例4: translation
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
* Translate une géométrie.
* Translate a geometry.
*
* @param geom une géométrie, a geometry
* @param dx translation suivant l'axe des x, translation along the X axis
* @param dy translation suivant l'axe des Y, translation along the Y axis
* @return polygone résultant de la translation, resulting polygon.
*/
public static Polygon translation(Polygon geom, double dx, double dy){
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(coord[i].x+dx, coord[i].y+dy);
LinearRing lr=gf.createLinearRing(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(hole_coord[i].x+dx, hole_coord[i].y+dy);
trous[j]=gf.createLinearRing(hole_coord_);
}
return gf.createPolygon(lr,trous);
}
示例5: reverseRing
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
* Does what it says, reverses the order of the Coordinates in the ring.
* <p>
* This is different then lr.reverses() in that a copy is produced using a
* new coordinate sequence.
* </p>
*
* @param lr The ring to reverse.
* @return A new ring with the reversed Coordinates.
*/
public static final LinearRing reverseRing(LinearRing lr) {
GeometryFactory gf = lr.getFactory();
CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
CoordinateSequence csOrig = lr.getCoordinateSequence();
int numPoints = csOrig.size();
int dimensions = csOrig.getDimension();
CoordinateSequence csNew = csf.create(numPoints, dimensions);
for (int i = 0; i < numPoints; i++) {
for (int j = 0; j < dimensions; j++) {
csNew.setOrdinate(numPoints - 1 - i, j, csOrig.getOrdinate(i, j));
}
}
return gf.createLinearRing(csNew);
}
示例6: toPolygon
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static Geometry toPolygon(Vertex[] v) {
Coordinate[] ringPts = new Coordinate[] { v[0].getCoordinate(),
v[1].getCoordinate(), v[2].getCoordinate(), v[0].getCoordinate() };
GeometryFactory fact = new GeometryFactory();
LinearRing ring = fact.createLinearRing(ringPts);
Polygon tri = fact.createPolygon(ring, null);
return tri;
}
示例7: rotation
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static Polygon rotation(Polygon geom, Coordinate c, double angle) {
double cos = Math.cos(angle), sin = Math.sin(angle);
GeometryFactory gf = new GeometryFactory();
// rotation de l'enveloppe
Coordinate[] coord = geom.getExteriorRing().getCoordinates();
Coordinate[] coord_ = new Coordinate[coord.length];
for (int i = 0; i < coord.length; i++) {
double x = coord[i].x, y = coord[i].y;
coord_[i] = new Coordinate(c.x + cos * (x - c.x) - sin * (y - c.y),
c.y + sin * (x - c.x) + cos * (y - c.y));
}
LinearRing lr = gf.createLinearRing(coord_);
// rotation des trous
LinearRing[] trous = new LinearRing[geom.getNumInteriorRing()];
for (int j = 0; j < geom.getNumInteriorRing(); j++) {
Coordinate[] coord2 = geom.getInteriorRingN(j).getCoordinates();
Coordinate[] coord2_ = new Coordinate[coord2.length];
for (int i = 0; i < coord2.length; i++) {
double x = coord2[i].x, y = coord2[i].y;
coord2_[i] = new Coordinate(c.x + cos * (x - c.x) - sin * (y - c.y),
c.y + sin * (x - c.x) + cos * (y - c.y));
}
trous[j] = gf.createLinearRing(coord2_);
}
return gf.createPolygon(lr, trous);
}
示例8: getPolygon
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public Polygon getPolygon() {
if (polygon == null) {
//CHECKSTYLE:OFF
double[][] rawLocations = new double[][] { { -4.652710, 54.069059 },
{ -4.634857, 54.075506 }, { -4.629364, 54.059388 }, { -4.600525, 54.087590 },
{ -4.574432, 54.102892 }, { -4.548340, 54.103697 }, { -4.522247, 54.124626 },
{ -4.476929, 54.143132 }, { -4.470062, 54.162434 }, { -4.428864, 54.169670 },
{ -4.383545, 54.194583 }, { -4.398651, 54.209846 }, { -4.397278, 54.223496 },
{ -4.373932, 54.229919 }, { -4.364319, 54.249180 }, { -4.301147, 54.303704 },
{ -4.372559, 54.315722 }, { -4.380798, 54.344550 }, { -4.365692, 54.389354 },
{ -4.364319, 54.420528 }, { -4.459076, 54.402946 }, { -4.534607, 54.373359 },
{ -4.578552, 54.322931 }, { -4.601898, 54.285270 }, { -4.636230, 54.258807 },
{ -4.671936, 54.237143 }, { -4.703522, 54.229919 }, { -4.728241, 54.187352 },
{ -4.743347, 54.173689 }, { -4.735107, 54.143132 }, { -4.755707, 54.110138 },
{ -4.783173, 54.101281 }, { -4.777679, 54.086784 }, { -4.822998, 54.049714 },
{ -4.737854, 54.066642 }, { -4.709015, 54.082757 }, { -4.682922, 54.062612 },
{ -4.652710, 54.069059 }, };
//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++;
}
LinearRing ring = geometryFactory.createLinearRing(coords);
LinearRing holes[] = null; // use LinearRing[] to represent holes
polygon = geometryFactory.createPolygon(ring, holes);
}
return polygon;
}
示例9: linearRing
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
protected static LinearRing linearRing(GeometryFactory factory, List<Coordinate> coordinates) {
return factory.createLinearRing(coordinates.toArray(new Coordinate[coordinates.size()]));
}
示例10: main
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
List<Area> areas = AreasUtils.getAllAreas("static-data/polygons.csv");
Map<String, Boolean> areasMap = new HashMap<>();
int i = 0;
try (BufferedReader br =
new BufferedReader(new FileReader("/opt/datAcron/insitu/data/output/nari_out.csv"))) {
String messageLine;
while ((messageLine = br.readLine()) != null) {
i++;
String[] split = messageLine.split(",");
if (split.length == 29) {
String areasStr = split[28];
Set<Area> newDetectedAreas = new HashSet<Area>();
for (Area area : areas) {
boolean x =
GeoUtils.isPointInPolygon(area.getPolygon(), Double.parseDouble(split[2]),
Double.parseDouble(split[3]));
if (x == true) {
if (!areasStr.contains(area.getId()))
System.out.println("old:" + areasStr + "\nnew:" + area.getId());
}
}
}
}
}
//
System.out.println(areasMap.keySet().size());
System.out.println("File lines:" + i);
System.out.println("areas=" + areas.size());
StringBuilder filterAreas = new StringBuilder();
long start = System.currentTimeMillis();
System.out.println("time= " + (System.currentTimeMillis() - start));
byte[] messageBytes = filterAreas.toString().getBytes();
// Files.write(Paths.get("src/main/resources/static-data/new-ploygons.csv"), messageBytes,
// StandardOpenOption.CREATE_NEW);
String test =
"area1488486400|-3.599999999999999,49.800705375|-3.604459,49.800148|-3.6047180123333384,49.8|-3.6999999999999993,49.8|-3.6999999999999993,49.9|-3.599999999999999,49.9";
String[] splits = test.split("\\|");
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Coordinate[] coords =
new Coordinate[] {new Coordinate(4, 0), new Coordinate(2, 2), new Coordinate(4, 4),
new Coordinate(6, 2), new Coordinate(4, 0)};
LinearRing ring = geometryFactory.createLinearRing(coords);
LinearRing holes[] = null; // use LinearRing[] to represent holes
Polygon polygon = geometryFactory.createPolygon(ring, holes);
System.out.println(splits);
String[] fields =
"1453984747,1,215130000,1,29.2796666666667,40.8366833333333,307,0,,".split(",", -1);
System.out.println(fields.length);
System.out.println(configs.getStringProp("streamSourceType"));
}
示例11: getGeometry
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public Polygon getGeometry(GeometryFactory fact) {
LinearRing ring = fact.createLinearRing(this.getCoordinates());
Polygon tri = fact.createPolygon(ring, null);
return tri;
}
示例12: processSurfacicGrid
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
* Cette fonction permet d'extraire en géométrie géoxygene les triangles du
* MNT compris dans le rectangle formé par dpMin et dpMax en 2D
*
* @param dpMin point inférieur gauche du rectangle
* @param dpMax point supérieur droit du rectangle
* @return une liste de polygones décrivant les géométries du MNT compris dans
* le rectangle formé par les 2 points en 2D
*/
@Override
public MultiPolygon processSurfacicGrid(double xmin, double xmax,
double ymin, double ymax) {
GeometryFactory fac = new GeometryFactory();
// On récupère dans quels triangles se trouvent dpMin et dpMax
int posxMin = (int) ((xmin - this.xIni) / (this.stepX * this.sampling));
int posyMin = (int) ((ymin - this.yIni) / (this.stepY * this.sampling));
int posxMax = 1 + (int) ((xmax - this.xIni) / (this.stepX * this.sampling));
int posyMax = 1 + (int) ((ymax - this.yIni) / (this.stepY * this.sampling));
// On récupère les sommets extérieurs de ces triangles (ceux qui
// permettent d'englober totalement le rectangle dpMin, dpMax
Coordinate dpOrigin = new Coordinate(posxMin * this.stepX + this.xIni,
posyMin * this.stepY + this.yIni);
Coordinate dpFin = new Coordinate(posxMax * this.stepX + this.xIni, posyMax
* this.stepY + this.yIni);
// On évalue le nombre de mailles à couvrir
int nbInterX = Math.max(1, (int) ((dpFin.x - dpOrigin.x) / this.stepX));
int nbInterY = Math.max(1,
(int) ((int) ((dpFin.y - dpOrigin.y) / this.stepY)));
Polygon[] lPolys = new Polygon[2 * nbInterX * nbInterY];
int indPoly = 0;
// On crée une géométrie géoxygne pour chacune de ces mailles
// (2 triangles par maille)
for (int i = 0; i < nbInterX; i++) {
for (int j = 0; j < nbInterY; j++) {
Coordinate dp1 = new Coordinate(dpOrigin.x + i * this.stepX, dpOrigin.y
+ j * this.stepY);
Coordinate dp2 = new Coordinate(dpOrigin.x + (i + 1) * this.stepX,
dpOrigin.y + j * this.stepY);
Coordinate dp3 = new Coordinate(dpOrigin.x + i * this.stepX, dpOrigin.y
+ (j + 1) * this.stepY);
Coordinate dp4 = new Coordinate(dpOrigin.x + (i + 1) * this.stepX,
dpOrigin.y + (j + 1) * this.stepY);
Coordinate[] coord = new Coordinate[4];
coord[0] = dp1;
coord[1] = dp2;
coord[2] = dp4;
coord[3] = dp1;
LinearRing l1 = fac.createLinearRing(coord);
Coordinate[] coord2 = new Coordinate[4];
coord2[0] = dp1;
coord2[1] = dp4;
coord2[2] = dp3;
coord2[3] = dp1;
LinearRing l2 = fac.createLinearRing(coord2);
lPolys[indPoly] = fac.createPolygon(l1, null);
indPoly++;
lPolys[indPoly] = fac.createPolygon(l2, null);
indPoly++;
}
}
// On renvoie la liste des triangles
return fac.createMultiPolygon(lPolys);
}
示例13: calcul3DArea
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
* Calculate 3D area from a polygon
* @param poly
* @return 3D area
* @throws Exception
*/
public double calcul3DArea(Polygon poly) {
GeometryFactory fac = new GeometryFactory();
double area = 0;
// On récupère les coordonnées extrêmes de l'enveloppes
Coordinate[] coordEnv = poly.getEnvelope().getCoordinates();
double xmin = coordEnv[0].x;
double xmax = coordEnv[2].x;
double ymin = coordEnv[0].y;
double ymax = coordEnv[2].y;
// On récupère dans quels triangles se trouvent dpMin et dpMax
int posxMin = (int) (-1 + (xmin - this.xIni) / (this.stepX * this.sampling));
int posyMin = (int) (-1 + (ymin - this.yIni) / (this.stepY * this.sampling));
int posxMax = 1 + (int) ((xmax - this.xIni) / (this.stepX * this.sampling));
int posyMax = 1 + (int) ((ymax - this.yIni) / (this.stepY * this.sampling));
// On récupère les sommets extérieurs de ces triangles (ceux qui
// permettent d'englober totalement le rectangle dpMin, dpMax
Coordinate dpOrigin = new Coordinate(posxMin * this.stepX + this.xIni, posyMin * this.stepY
+ this.yIni);
Coordinate dpFin = new Coordinate(posxMax * this.stepX + this.xIni, posyMax * this.stepY
+ this.yIni);
// On évalue le nombre de mailles à couvrir
int nbInterX = (int) ((dpFin.x - dpOrigin.x) / this.stepX);
int nbInterY = (int) ((dpFin.y - dpOrigin.y) / this.stepY);
// On crée une géométrie géoxygne pour chacune de ces mailles
// (2 triangles par maille)
for (int i = 0; i < nbInterX; i++) {
for (int j = 0; j < nbInterY; j++) {
Coordinate dp1 = new Coordinate(dpOrigin.x + i * this.stepX, dpOrigin.y + j * this.stepY);
Coordinate dp2 = new Coordinate(dpOrigin.x + (i + 1) * this.stepX, dpOrigin.y + j
* this.stepY);
Coordinate dp3 = new Coordinate(dpOrigin.x + i * this.stepX, dpOrigin.y + (j + 1)
* this.stepY);
Coordinate dp4 = new Coordinate(dpOrigin.x + (i + 1) * this.stepX, dpOrigin.y + (j + 1)
* this.stepY);
Coordinate[] coord = new Coordinate[4];
coord[0] = dp1;
coord[1] = dp2;
coord[2] = dp4;
coord[3] = dp1;
LinearRing l1 = fac.createLinearRing(coord);
Coordinate[] coord2 = new Coordinate[4];
coord2[0] = dp1;
coord2[1] = dp4;
coord2[2] = dp3;
coord2[3] = dp1;
LinearRing l2 = fac.createLinearRing(coord2);
// Les 2 triangles du MNT que l'on étudie
Polygon poly1 = fac.createPolygon(l1, null);
Polygon poly2 = fac.createPolygon(l2, null);
area = area + this.contributionForTriangle(poly, poly1)
+ this.contributionForTriangle(poly, poly2);
}
}
return area;
}
示例14: getPolygon
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public Polygon getPolygon() {
if (polygon == null) {
//CHECKSTYLE:OFF
double[][] rawLocations = new double[][] { { -4.49210295036, 54.4153472858 },
{ -4.4634856663, 54.4269825687 }, { -4.43426958965, 54.4117153967 },
{ -4.40869623532, 54.4326291409 }, { -4.32782927985, 54.4641980089 },
{ -4.3659606463, 54.4197683392 }, { -4.33467823679, 54.4265693547 },
{ -4.32454274819, 54.4024986924 }, { -4.34126081686, 54.3660155026 },
{ -4.3424304253, 54.3042112639 }, { -4.37506398925, 54.3014094498 },
{ -4.41392105869, 54.2658635384 }, { -4.44375514123, 54.2532227674 },
{ -4.44763651915, 54.196776024 }, { -4.48315404347, 54.1850220956 },
{ -4.52311962815, 54.1455956993 }, { -4.58362722513, 54.1091637546 },
{ -4.62431015799, 54.0527236394 }, { -4.71452726534, 54.0188283696 },
{ -4.71863162723, 54.0497614848 }, { -4.75157122164, 54.0647816773 },
{ -4.79755603397, 54.0685543663 }, { -4.79717105693, 54.122792557 },
{ -4.74451711581, 54.1875314993 }, { -4.73842361793, 54.2081776896 },
{ -4.71656215204, 54.2185876346 }, { -4.71759940991, 54.2322672444 },
{ -4.73514361565, 54.2446507516 }, { -4.69488449392, 54.2771110727 },
{ -4.65558887927, 54.2914459801 }, { -4.65220617099, 54.3116519242 },
{ -4.63949760848, 54.3400051903 }, { -4.58879948143, 54.3629767901 },
{ -4.57315512904, 54.3829958979 }, { -4.54023908795, 54.387968746 },
{ -4.51678123729, 54.4207829193 }, { -4.50855200379, 54.405875113 },
{ -4.49210295036, 54.4153472858 }, };
//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++;
}
LinearRing ring = geometryFactory.createLinearRing(coords);
LinearRing holes[] = null; // use LinearRing[] to represent holes
polygon = geometryFactory.createPolygon(ring, holes);
}
return polygon;
}