本文整理匯總了Java中com.vividsolutions.jts.geom.MultiLineString.setSRID方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiLineString.setSRID方法的具體用法?Java MultiLineString.setSRID怎麽用?Java MultiLineString.setSRID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.MultiLineString
的用法示例。
在下文中一共展示了MultiLineString.setSRID方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseJson
import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
private MultiLineString parseJson(String json) {
JSONObject obj = null;
MultiLineString multiLine = null;
GeometryFactory geomF = new GeometryFactory(new PrecisionModel(), 4326);
try {
obj = new JSONObject(json);
String type = obj.getString("type");
if (!type.equals("MultiLineString")) {
return null;
} else {
List<LineString> lineList = new ArrayList<LineString>();
// get lines of MultiLineString
JSONArray lines = obj.getJSONArray("coordinates");
for (int i = 0; i < lines.length(); i++) {
// get points of line
JSONArray points = lines.getJSONArray(i);
List<Coordinate> pointList = new ArrayList<Coordinate>();
for (int a = 0; a < points.length(); a++) {
// get coordinate
JSONArray coord = points.getJSONArray(a);
pointList.add(new Coordinate(coord.getDouble(0), coord.getDouble(1), coord.getDouble(2)));
}
lineList.add(geomF.createLineString(pointList.toArray(new Coordinate[pointList.size()])));
}
multiLine = geomF.createMultiLineString(lineList.toArray(new LineString[lineList.size()]));
multiLine.setSRID(4326);
}
} catch (JSONException e) {
e.printStackTrace();
}
return multiLine;
}
示例2: create
import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
/**
* Returns a completed multi type.
*
* @param geometryFactory The factory this method should use to create the
* multi type.
*
* @return Appropriate multi geometry type.
*/
public Geometry create(GeometryFactory geometryFactory) {
if (internalType.equals("Point")) {
Point[] pointArray = geometryFactory.toPointArray(geometries);
MultiPoint multiPoint = geometryFactory.createMultiPoint(pointArray);
multiPoint.setUserData( getSRS() );
multiPoint.setSRID( getSRID() );
return multiPoint;
} else if (internalType.equals("LineString")) {
LineString[] lineStringArray = geometryFactory
.toLineStringArray(geometries);
MultiLineString multiLineString = geometryFactory.createMultiLineString(lineStringArray);
multiLineString.setUserData( getSRS() );
multiLineString.setSRID( getSRID() );
return multiLineString;
} else if (internalType.equals("Polygon")) {
Polygon[] polygonArray = geometryFactory.toPolygonArray(geometries);
MultiPolygon multiPolygon = geometryFactory.createMultiPolygon(polygonArray);
multiPolygon.setUserData( getSRS() );
multiPolygon.setSRID( getSRID() );
return multiPolygon;
} else {
return null;
}
}
示例3: splitMultiLineString
import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
private MultiLineString[] splitMultiLineString(MultiLineString mLine, Coordinate c) {
List<LineString> lineArr1 = new ArrayList<LineString>();
List<LineString> lineArr2 = new ArrayList<LineString>();
List<Coordinate> coords1 = new ArrayList<Coordinate>();
List<Coordinate> coords2 = new ArrayList<Coordinate>();
boolean splittingPointReached = false;
for (int i = 0; i < mLine.getNumGeometries(); i++) {
LineString line = (LineString) mLine.getGeometryN(i);
for (int a = 0; a < line.getCoordinates().length - 1; a++) {
if (splittingPointReached == false) {
coords1.add(line.getCoordinates()[a]);
} else {
coords2.add(line.getCoordinates()[a]);
if (a == line.getCoordinates().length - 2) {
// add last coordinate
coords2.add(line.getCoordinates()[a + 1]);
}
}
// check whether current coordinate is equals to the given
// coordinate at which the MultiLineString has to be splitted
if (c.equals3D(line.getCoordinates()[a])) {
splittingPointReached = true;
}
}
if (coords1.size() > 1) {
lineArr1.add(geomF.createLineString(coords1.toArray(new Coordinate[coords1.size()])));
}
coords1 = new ArrayList<Coordinate>();
if (coords2.size() > 1) {
lineArr2.add(geomF.createLineString(coords2.toArray(new Coordinate[coords2.size()])));
}
coords2 = new ArrayList<Coordinate>();
}
// build Array
MultiLineString[] mLineArr = new MultiLineString[2];
MultiLineString mLine1 = geomF.createMultiLineString(lineArr1.toArray(new LineString[lineArr1.size()]));
mLine1.setSRID(4326);
MultiLineString mLine2 = geomF.createMultiLineString(lineArr2.toArray(new LineString[lineArr2.size()]));
mLine2.setSRID(4326);
mLineArr[0] = mLine1;
mLineArr[1] = mLine2;
return mLineArr;
}
示例4: addSmoothedZValues
import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
private void addSmoothedZValues(GpsTracePart part, Double[] eleSmoothed) {
GeometryFactory geomF = new GeometryFactory();
// create copy of geometry and exchange the z-values
// MultiLineString geomSmoothed = (MultiLineString)
// part.getGeom().clone();
int newValueCounter = 0;
// exchange z-Values
List<LineString> lines = new ArrayList<LineString>();
for (int i = 0; i < part.getGeom().getNumGeometries(); i++) {
List<Coordinate> coords = new ArrayList<Coordinate>();
Coordinate[] cArr = part.getGeom().getGeometryN(i).getCoordinates();
for (int a = 0; a < cArr.length; a++) {
Double newZ = eleSmoothed[newValueCounter];
if (!newZ.equals(Double.NaN)) {
Coordinate c = new Coordinate(cArr[a].x, cArr[a].y, newZ);
coords.add(c);
}
newValueCounter++;
}
// create line string and add to linestring list
if (coords.size() > 1) {
LineString line = geomF.createLineString(coords.toArray(new Coordinate[coords.size()]));
if (line.isValid()) {
lines.add(line);
}
}
}
if (!lines.isEmpty()) {
MultiLineString geomSmoothed = geomF.createMultiLineString(lines.toArray(new LineString[lines.size()]));
geomSmoothed.setSRID(4326);
part.setGeomSmoothed(geomSmoothed);
} else {
part.setGeomSmoothed(null);
}
}