public static void assertEquals(Geometry s1, Geometry s2) {
if(s1 instanceof LineString && s2 instanceof LineString) {
assertEquals((LineString) s1, (LineString) s2);
} else if (s1 instanceof Polygon && s2 instanceof Polygon) {
assertEquals((Polygon) s1, (Polygon) s2);
} else if (s1 instanceof MultiPoint && s2 instanceof MultiPoint) {
Assert.assertEquals(s1, s2);
} else if (s1 instanceof MultiPolygon && s2 instanceof MultiPolygon) {
assertEquals((MultiPolygon) s1, (MultiPolygon) s2);
} else if (s1 instanceof MultiLineString && s2 instanceof MultiLineString) {
assertEquals((MultiLineString) s1, (MultiLineString) s2);
} else {
throw new RuntimeException("equality of shape types not supported [" + s1.getClass().getName() + " and " + s2.getClass().getName() + "]");
}
}
java类com.vividsolutions.jts.geom.MultiLineString的实例源码
ElasticsearchGeoAssertions.java 文件源码
项目:elasticsearch_my
阅读 24
收藏 0
点赞 0
评论 0
JtsAdapter.java 文件源码
项目:vt-support
阅读 28
收藏 0
点赞 0
评论 0
/**
* Get the MVT type mapping for the provided JTS Geometry.
*
* @param geometry JTS Geometry to get MVT type for
* @return MVT type for the given JTS Geometry, may return
* {@link uk.os.vt.mvt.VectorTile.Tile.GeomType#UNKNOWN}
*/
public static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
VectorTile.Tile.GeomType result = VectorTile.Tile.GeomType.UNKNOWN;
if (geometry instanceof Point
|| geometry instanceof MultiPoint) {
result = VectorTile.Tile.GeomType.POINT;
} else if (geometry instanceof LineString
|| geometry instanceof MultiLineString) {
result = VectorTile.Tile.GeomType.LINESTRING;
} else if (geometry instanceof Polygon
|| geometry instanceof MultiPolygon) {
result = VectorTile.Tile.GeomType.POLYGON;
}
return result;
}
LineSequencer.java 文件源码
项目:Earth
阅读 23
收藏 0
点赞 0
评论 0
private void computeSequence() {
if (this.isRun) {
return;
}
this.isRun = true;
List sequences = this.findSequences();
if (sequences == null) {
return;
}
this.sequencedGeometry = this.buildSequencedGeometry(sequences);
this.isSequenceable = true;
int finalLineCount = this.sequencedGeometry.getNumGeometries();
Assert.isTrue(this.lineCount == finalLineCount, "Lines were missing from result");
Assert.isTrue(this.sequencedGeometry instanceof LineString
|| this.sequencedGeometry instanceof MultiLineString,
"Result is not lineal");
}
IsSimpleOp.java 文件源码
项目:Earth
阅读 26
收藏 0
点赞 0
评论 0
private boolean computeSimple(Geometry geom) {
this.nonSimpleLocation = null;
if (geom.isEmpty()) {
return true;
}
if (geom instanceof LineString) {
return this.isSimpleLinearGeometry(geom);
}
if (geom instanceof MultiLineString) {
return this.isSimpleLinearGeometry(geom);
}
if (geom instanceof MultiPoint) {
return this.isSimpleMultiPoint((MultiPoint) geom);
}
if (geom instanceof Polygonal) {
return this.isSimplePolygonal(geom);
}
if (geom instanceof GeometryCollection) {
return this.isSimpleGeometryCollection(geom);
}
// all other geometry types are simple by definition
return true;
}
OffsetCurveSetBuilder.java 文件源码
项目:Earth
阅读 33
收藏 0
点赞 0
评论 0
private void add(Geometry g) {
if (g.isEmpty()) {
return;
}
if (g instanceof Polygon) {
this.addPolygon((Polygon) g);
}
// LineString also handles LinearRings
else if (g instanceof LineString) {
this.addLineString((LineString) g);
} else if (g instanceof Point) {
this.addPoint((Point) g);
} else if (g instanceof MultiPoint) {
this.addCollection((MultiPoint) g);
} else if (g instanceof MultiLineString) {
this.addCollection((MultiLineString) g);
} else if (g instanceof MultiPolygon) {
this.addCollection((MultiPolygon) g);
} else if (g instanceof GeometryCollection) {
this.addCollection((GeometryCollection) g);
} else {
throw new UnsupportedOperationException(g.getClass().getName());
}
}
BoundaryOp.java 文件源码
项目:Earth
阅读 27
收藏 0
点赞 0
评论 0
private Coordinate[] computeBoundaryCoordinates(MultiLineString mLine) {
List bdyPts = new ArrayList();
this.endpointMap = new TreeMap();
for (int i = 0; i < mLine.getNumGeometries(); i++) {
LineString line = (LineString) mLine.getGeometryN(i);
if (line.getNumPoints() == 0) {
continue;
}
this.addEndpoint(line.getCoordinateN(0));
this.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
}
for (Object o : endpointMap.entrySet()) {
Map.Entry entry = (Map.Entry) o;
Counter counter = (Counter) entry.getValue();
int valence = counter.count;
if (this.bnRule.isInBoundary(valence)) {
bdyPts.add(entry.getKey());
}
}
return CoordinateArrays.toCoordinateArray(bdyPts);
}
ShapeWriter.java 文件源码
项目:Earth
阅读 25
收藏 0
点赞 0
评论 0
/**
* Creates a {@link Shape} representing a {@link Geometry},
* according to the specified PointTransformation
* and PointShapeFactory (if relevant).
* <p>
* Note that Shapes do not
* preserve information about which elements in heterogeneous collections
* are 1D and which are 2D.
* For example, a GeometryCollection containing a ring and a
* disk will render as two disks if Graphics.fill is used,
* or as two rings if Graphics.draw is used.
* To avoid this issue use separate shapes for the components.
*
* @param geometry the geometry to convert
* @return a Shape representing the geometry
*/
public Shape toShape(Geometry geometry) {
if (geometry.isEmpty()) {
return new GeneralPath();
}
if (geometry instanceof Polygon) {
return this.toShape((Polygon) geometry);
}
if (geometry instanceof LineString) {
return this.toShape((LineString) geometry);
}
if (geometry instanceof MultiLineString) {
return this.toShape((MultiLineString) geometry);
}
if (geometry instanceof Point) {
return this.toShape((Point) geometry);
}
if (geometry instanceof GeometryCollection) {
return this.toShape((GeometryCollection) geometry);
}
throw new IllegalArgumentException(
"Unrecognized Geometry class: " + geometry.getClass());
}
GMLWriter.java 文件源码
项目:Earth
阅读 24
收藏 0
点赞 0
评论 0
private void write(Geometry geom, Writer writer, int level)
throws IOException {
this.isRootTag = true;
if (geom instanceof Point) {
this.writePoint((Point) geom, writer, level);
} else if (geom instanceof LineString) {
this.writeLineString((LineString) geom, writer, level);
} else if (geom instanceof Polygon) {
this.writePolygon((Polygon) geom, writer, level);
} else if (geom instanceof MultiPoint) {
this.writeMultiPoint((MultiPoint) geom, writer, level);
} else if (geom instanceof MultiLineString) {
this.writeMultiLineString((MultiLineString) geom, writer, level);
} else if (geom instanceof MultiPolygon) {
this.writeMultiPolygon((MultiPolygon) geom, writer, level);
} else if (geom instanceof GeometryCollection) {
this.writeGeometryCollection((GeometryCollection) geom, writer,
this.startingIndentIndex);
} else {
throw new IllegalArgumentException("Unhandled geometry type: "
+ geom.getGeometryType());
}
writer.flush();
}
GMLWriter.java 文件源码
项目:Earth
阅读 26
收藏 0
点赞 0
评论 0
private void writeMultiLineString(MultiLineString mls, Writer writer,
int level) throws IOException {
this.startLine(level, writer);
this.startGeomTag(GMLConstants.GML_MULTI_LINESTRING, mls, writer);
for (int t = 0; t < mls.getNumGeometries(); t++) {
this.startLine(level + 1, writer);
this.startGeomTag(GMLConstants.GML_LINESTRING_MEMBER, null, writer);
this.writeLineString((LineString) mls.getGeometryN(t), writer, level + 2);
this.startLine(level + 1, writer);
this.endGeomTag(GMLConstants.GML_LINESTRING_MEMBER, writer);
}
this.startLine(level, writer);
this.endGeomTag(GMLConstants.GML_MULTI_LINESTRING, writer);
}
WKBWriter.java 文件源码
项目:Earth
阅读 29
收藏 0
点赞 0
评论 0
/**
* Writes a {@link Geometry} to an {@link OutStream}.
*
* @param geom the geometry to write
* @param os the out stream to write to
* @throws IOException if an I/O error occurs
*/
public void write(Geometry geom, OutStream os) throws IOException {
if (geom instanceof Point) {
this.writePoint((Point) geom, os);
}
// LinearRings will be written as LineStrings
else if (geom instanceof LineString) {
this.writeLineString((LineString) geom, os);
} else if (geom instanceof Polygon) {
this.writePolygon((Polygon) geom, os);
} else if (geom instanceof MultiPoint) {
this.writeGeometryCollection(WKBConstants.wkbMultiPoint,
(MultiPoint) geom, os);
} else if (geom instanceof MultiLineString) {
this.writeGeometryCollection(WKBConstants.wkbMultiLineString,
(MultiLineString) geom, os);
} else if (geom instanceof MultiPolygon) {
this.writeGeometryCollection(WKBConstants.wkbMultiPolygon,
(MultiPolygon) geom, os);
} else if (geom instanceof GeometryCollection) {
this.writeGeometryCollection(WKBConstants.wkbGeometryCollection,
(GeometryCollection) geom, os);
} else {
Assert.shouldNeverReachHere("Unknown Geometry type");
}
}
WKTWriter.java 文件源码
项目:Earth
阅读 23
收藏 0
点赞 0
评论 0
/**
* Converts a <code>MultiLineString</code> to <MultiLineString Text>
* format, then appends it to the writer.
*
* @param multiLineString the <code>MultiLineString</code> to process
* @param writer the output writer to append to
*/
private void appendMultiLineStringText(MultiLineString multiLineString, int level, boolean indentFirst,
Writer writer)
throws IOException {
if (multiLineString.isEmpty()) {
writer.write("EMPTY");
} else {
int level2 = level;
boolean doIndent = indentFirst;
writer.write("(");
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
if (i > 0) {
writer.write(", ");
level2 = level + 1;
doIndent = true;
}
this.appendLineStringText((LineString) multiLineString.getGeometryN(i), level2, doIndent, writer);
}
writer.write(")");
}
}
AdapterFactory.java 文件源码
项目:geoxygene
阅读 36
收藏 0
点赞 0
评论 0
/**
* Traduit un type de géométrie JTS {@link Geometry} et renvoie le type de
* géométrie GeOxygene {@link IGeometry} équivalent. TODO gérer tous les types
* de géométrie.
* @param geometryType type de géométrie JTS
* @return type de géométrie GeOxygene équivalent
*/
public static Class<? extends IGeometry> toGeometryType(Class<?> geometryType) {
if (LineString.class.equals(geometryType)) {
return ILineString.class;
}
if (MultiLineString.class.equals(geometryType)) {
return IMultiCurve.class;
}
if (Polygon.class.equals(geometryType)) {
return IPolygon.class;
}
if (MultiPolygon.class.equals(geometryType)) {
return IMultiSurface.class;
}
if (Point.class.equals(geometryType)) {
return IPoint.class;
}
if (MultiPoint.class.equals(geometryType)) {
return IMultiPoint.class;
}
return IGeometry.class;
}
AdapterFactory.java 文件源码
项目:geoxygene
阅读 30
收藏 0
点赞 0
评论 0
/**
* Traduit un type de géométrie GeOxygene {@link IGeometry} et renvoie le type
* de géométrie JTS {@link Geometry} équivalent. TODO gérer tous les types de
* géométrie.
* @param geometryType type de géométrie GeOxygene
* @return type de géométrie JTS équivalent
*/
public static Class<? extends Geometry> toJTSGeometryType(
Class<?> geometryType) {
if (ILineString.class.isAssignableFrom(geometryType)) {
return LineString.class;
}
if (IMultiCurve.class.isAssignableFrom(geometryType)) {
return MultiLineString.class;
}
if (IPolygon.class.isAssignableFrom(geometryType)) {
return Polygon.class;
}
if (IMultiSurface.class.isAssignableFrom(geometryType)) {
return MultiPolygon.class;
}
if (IPoint.class.isAssignableFrom(geometryType)) {
return Point.class;
}
if (IMultiPoint.class.isAssignableFrom(geometryType)) {
return MultiPoint.class;
}
if (IAggregate.class.isAssignableFrom(geometryType)) {
return GeometryCollection.class;
}
return Geometry.class;
}
AllowedAttributeTypes.java 文件源码
项目:sldeditor
阅读 21
收藏 0
点赞 0
评论 0
/**
* Initialise.
*/
private static void initialise()
{
List<Class<?> > doubleList = new ArrayList<Class<?> >(Arrays.asList(Integer.class, Long.class, Double.class, Float.class));
List<Class<?> > integerList = new ArrayList<Class<?> >(Arrays.asList(Integer.class, Long.class));
List<Class<?> > stringList = new ArrayList<Class<?> >(Arrays.asList(String.class));
List<Class<?> > geometryList = new ArrayList<Class<?> >(Arrays.asList(Point.class, LineString.class, Polygon.class, MultiPolygon.class, MultiPoint.class, MultiLineString.class));
allowedClassTypeMap.put(String.class, stringList);
allowedClassTypeMap.put(Double.class, doubleList);
allowedClassTypeMap.put(Float.class, doubleList);
allowedClassTypeMap.put(Integer.class, integerList);
allowedClassTypeMap.put(Long.class, integerList);
allowedClassTypeMap.put(Geometry.class, geometryList);
List<Class<?> > objectList = new ArrayList<Class<?>>();
objectList.addAll(doubleList);
objectList.addAll(integerList);
objectList.addAll(stringList);
objectList.addAll(geometryList);
allowedClassTypeMap.put(Object.class, objectList);
}
VectorTileEncoder.java 文件源码
项目:gs-mvt
阅读 28
收藏 0
点赞 0
评论 0
static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
if (geometry instanceof Point) {
return VectorTile.Tile.GeomType.POINT;
}
if (geometry instanceof MultiPoint) {
return VectorTile.Tile.GeomType.POINT;
}
if (geometry instanceof LineString) {
return VectorTile.Tile.GeomType.LINESTRING;
}
if (geometry instanceof MultiLineString) {
return VectorTile.Tile.GeomType.LINESTRING;
}
if (geometry instanceof Polygon) {
return VectorTile.Tile.GeomType.POLYGON;
}
return VectorTile.Tile.GeomType.UNKNOWN;
}
App.java 文件源码
项目:MapMatching
阅读 33
收藏 0
点赞 0
评论 0
/**
* A simple function that will verify if a feature source contains line strings or not.
*
* @param FeatureSource<?, ?> source The source you wish to check.
* @return boolean Returns true if the source contains line strings, otherwise it will return false.
*/
private static boolean verifyLine(FeatureSource<?, ?> source){
//Verify that the feature contains lines.
Class<?> geomBinding = source.getSchema().getGeometryDescriptor().getType().getBinding();
boolean isLine = geomBinding != null
&& (LineString.class.isAssignableFrom(geomBinding) ||
MultiLineString.class.isAssignableFrom(geomBinding));
//Otherwise, return false.
if(!isLine){
return false;
}
return true;
}
SaveStatement.java 文件源码
项目:gama
阅读 27
收藏 0
点赞 0
评论 0
public String getGeometryType(final List<? extends IShape> agents) {
String geomType = "";
for (final IShape be : agents) {
final IShape geom = be.getGeometry();
if (geom != null) {
geomType = geom.getInnerGeometry().getClass().getSimpleName();
if (geom.getInnerGeometry().getNumGeometries() > 1) {
if (geom.getInnerGeometry().getGeometryN(0).getClass() == Point.class) {
geomType = MultiPoint.class.getSimpleName();
} else if (geom.getInnerGeometry().getGeometryN(0).getClass() == LineString.class) {
geomType = MultiLineString.class.getSimpleName();
} else if (geom.getInnerGeometry().getGeometryN(0).getClass() == Polygon.class) {
geomType = MultiPolygon.class.getSimpleName();
}
break;
}
}
}
if ("DynamicLineString".equals(geomType))
geomType = LineString.class.getSimpleName();
return geomType;
}
GridMaker.java 文件源码
项目:RainInterpolator
阅读 21
收藏 0
点赞 0
评论 0
/**
* This methods works out what sort of feature geometry we have in the
* shapefile and then delegates to an appropriate style creating method.
*/
private Style createStyle(FeatureSource featureSource) {
SimpleFeatureType schema = (SimpleFeatureType) featureSource.getSchema();
Class geomType = schema.getGeometryDescriptor().getType().getBinding();
if (Polygon.class.isAssignableFrom(geomType)
|| MultiPolygon.class.isAssignableFrom(geomType)) {
return createPolygonStyle();
} else if (LineString.class.isAssignableFrom(geomType)
|| MultiLineString.class.isAssignableFrom(geomType)) {
return createLineStyle();
} else {
return createPointStyle();
}
}
ParseShapefiles.java 文件源码
项目:RainInterpolator
阅读 22
收藏 0
点赞 0
评论 0
private static GeometryTypeString parseGeometry(GeometryType type) {
GeometryTypeString geometryType;
//Geometry type
Class<?> clazz = type.getBinding();
if (Polygon.class.isAssignableFrom(clazz)
|| MultiPolygon.class.isAssignableFrom(clazz)) {
geometryType = GeometryTypeString.POLYGON;
} else if (LineString.class.isAssignableFrom(clazz)
|| MultiLineString.class.isAssignableFrom(clazz)) {
geometryType = GeometryTypeString.LINE;
} else {
geometryType = GeometryTypeString.POINT;
}
return geometryType;
}
GeometryUtils.java 文件源码
项目:platypus-js
阅读 27
收藏 0
点赞 0
评论 0
public static boolean isValidGeometryData(List<Geometry> aData, Class aGeometryClass) {
if (Point.class.isAssignableFrom(aGeometryClass)
|| LineString.class.isAssignableFrom(aGeometryClass)
|| Polygon.class.isAssignableFrom(aGeometryClass)) {
return aData.size() == 1 && isValidGeometryDataSection(aData.get(0).getCoordinates(), aGeometryClass);
} else if (MultiPoint.class.isAssignableFrom(aGeometryClass)
|| MultiLineString.class.isAssignableFrom(aGeometryClass)
|| MultiPolygon.class.isAssignableFrom(aGeometryClass)) {
if (aData.size() >= 1) {
for (int i = 0; i < aData.size(); i++) {
if (!isValidGeometryDataSection(aData.get(i).getCoordinates(), aGeometryClass)) {
return false;
}
}
return true;
} else {
return false;
}
} else {
return false;
}
}
OmsLW08_NetworkBufferWidthCalculator.java 文件源码
项目:hortonmachine
阅读 24
收藏 0
点赞 0
评论 0
private ArrayList<Geometry> getPolygonBetweenLines( ArrayList<SimpleFeature> newLinesFeatures ) {
ArrayList<Geometry> polygons = new ArrayList<Geometry>();
for( int i = 0; i < newLinesFeatures.size() - 1; i++ ) {
SimpleFeature f1 = newLinesFeatures.get(i);
SimpleFeature f2 = newLinesFeatures.get(i + 1);
LineString l1 = (LineString) f1.getDefaultGeometry();
LineString l2 = (LineString) f2.getDefaultGeometry();
MultiLineString multiLine = gf.createMultiLineString(new LineString[]{l1, l2});
Geometry convexHull = multiLine.convexHull();
Geometry buffer = convexHull.buffer(0.1);
polygons.add(buffer);
}
return polygons;
}
LayerCollection.java 文件源码
项目:geokettle-2.0
阅读 29
收藏 0
点赞 0
评论 0
public void addGeometryToCollection(Geometry geom, boolean batchMode, int featureIndex){
if (geom!=null){
int type = -1;
if(geom instanceof Point || geom instanceof MultiPoint){
type = Layer.POINT_LAYER;
layers.get(type).addGeometry((Geometry)geom, batchMode);
featureIndexes.get(type).add(featureIndex);
}else if(geom instanceof LineString || geom instanceof MultiLineString){
type = Layer.LINE_LAYER;
layers.get(type).addGeometry((Geometry)geom, batchMode);
featureIndexes.get(type).add(featureIndex);
}else if(geom instanceof Polygon || geom instanceof MultiPolygon){
type = Layer.POLYGON_LAYER;
layers.get(type).addGeometry((Geometry)geom, batchMode);
featureIndexes.get(type).add(featureIndex);
}else if(geom instanceof GeometryCollection){
type = Layer.COLLECTION_LAYER;
layers.get(type).setDisplayCount(layers.get(type).getDisplayCount()+1);
addGeometryCollection(geom, batchMode, featureIndex);
}
}
}
ShapefileLoader.java 文件源码
项目:snap-desktop
阅读 19
收藏 0
点赞 0
评论 0
private static Style[] createStyle(File shapeFile, FeatureType schema) {
final Style[] styles = SLDUtils.loadSLD(shapeFile);
if (styles != null && styles.length > 0) {
return styles;
}
Class<?> type = schema.getGeometryDescriptor().getType().getBinding();
if (type.isAssignableFrom(Polygon.class)
|| type.isAssignableFrom(MultiPolygon.class)) {
return new Style[]{createPolygonStyle()};
} else if (type.isAssignableFrom(LineString.class)
|| type.isAssignableFrom(MultiLineString.class)) {
return new Style[]{createLineStyle()};
} else {
return new Style[]{createPointStyle()};
}
}
StyleLab.java 文件源码
项目:geotools-cookbook
阅读 23
收藏 0
点赞 0
评论 0
/**
* Here is a programmatic alternative to using JSimpleStyleDialog to
* get a Style. This methods works out what sort of feature geometry
* we have in the shapefile and then delegates to an appropriate style
* creating method.
*/
private Style createStyle2(FeatureSource featureSource) {
SimpleFeatureType schema = (SimpleFeatureType)featureSource.getSchema();
Class geomType = schema.getGeometryDescriptor().getType().getBinding();
if (Polygon.class.isAssignableFrom(geomType)
|| MultiPolygon.class.isAssignableFrom(geomType)) {
return createPolygonStyle();
} else if (LineString.class.isAssignableFrom(geomType)
|| MultiLineString.class.isAssignableFrom(geomType)) {
return createLineStyle();
} else {
return createPointStyle();
}
}
SelectionLab.java 文件源码
项目:geotools-cookbook
阅读 25
收藏 0
点赞 0
评论 0
/**
* Retrieve information about the feature geometry
*/
private void setGeometry() {
GeometryDescriptor geomDesc = featureSource.getSchema().getGeometryDescriptor();
geometryAttributeName = geomDesc.getLocalName();
Class<?> clazz = geomDesc.getType().getBinding();
if (Polygon.class.isAssignableFrom(clazz) ||
MultiPolygon.class.isAssignableFrom(clazz)) {
geometryType = GeomType.POLYGON;
} else if (LineString.class.isAssignableFrom(clazz) ||
MultiLineString.class.isAssignableFrom(clazz)) {
geometryType = GeomType.LINE;
} else {
geometryType = GeomType.POINT;
}
}
ShapeWriter.java 文件源码
项目:geodroid_master_update
阅读 34
收藏 0
点赞 0
评论 0
/**
* Creates a {@link Shape} representing a {@link Geometry},
* according to the specified PointTransformation
* and PointShapeFactory (if relevant).
* <p>
* Note that Shapes do not
* preserve information about which elements in heterogeneous collections
* are 1D and which are 2D.
* For example, a GeometryCollection containing a ring and a
* disk will render as two disks if Graphics.fill is used,
* or as two rings if Graphics.draw is used.
* To avoid this issue use separate shapes for the components.
*
* @param geometry the geometry to convert
* @return a Shape representing the geometry
*/
public DrawableShape toShape( Geometry geometry ) {
if (geometry.isEmpty())
return new PathShape(new Path());
else if (geometry instanceof Polygon)
return toShape((Polygon) geometry);
else if (geometry instanceof MultiPolygon)
return toShape((MultiPolygon) geometry);
else if (geometry instanceof LineString)
return toShape((LineString) geometry);
else if (geometry instanceof MultiLineString)
return toShape((MultiLineString) geometry);
else if (geometry instanceof Point)
return toShape((Point) geometry);
else if (geometry instanceof MultiPoint)
return toShape((MultiPoint) geometry);
else if (geometry instanceof GeometryCollection)
return toShape((GeometryCollection) geometry);
throw new IllegalArgumentException("Unrecognized Geometry class: " + geometry.getClass());
}
GML32MultiGeometryGenerator.java 文件源码
项目:WPS4Aviation
阅读 23
收藏 0
点赞 0
评论 0
public void encodeAsXmlObject(Object geometry, List<Element> geoms) throws IOException, TransformerException, SAXException {
this.encoder = new Encoder(config);
this.encoder.setOmitXMLDeclaration(true);
if (geometry instanceof MultiPolygon) {
encodeMultiPolygon((MultiPolygon) geometry, geoms);
} else if (geometry instanceof Polygon) {
encodePolygon((Polygon) geometry, geoms);
} else if (geometry instanceof LinearRing) {
encodeLinearRing((LinearRing) geometry, geoms);
} else if (geometry instanceof LineString) {
encodeLineString((LineString) geometry, geoms);
} else if (geometry instanceof MultiLineString) {
encodeMultiLineString((MultiLineString) geometry, geoms);
} else if (geometry instanceof Point) {
encodePoint((Point) geometry, geoms);
} else if (geometry instanceof MultiPoint) {
encodeMultiPoint((MultiPoint) geometry, geoms);
}
}
GeometryHelper.java 文件源码
项目:Runway-SDK
阅读 27
收藏 0
点赞 0
评论 0
/**
* Return a MultiPolygon object that corresponds to the given Geometry
* object.
*
* For a point, we'll return a triangle centered around the point. For a
* LineString or MultiLineString, we'll return a MultiPolygon created by
* tracing the outline(s) of the LineString/MultiLineString. For a
* Polygon, we'll return a MultiPolygon that contains only that polygon For
* a MultiPolygon, we'll just return it
*
* @param g
* @return
*/
public MultiPolygon getGeoMultiPolygon(Geometry g) {
MultiPolygon geoMultiPolygon = null;
if (g instanceof Point) {
Coordinate[] points = this.createTriangle(g.getCoordinate());
geoMultiPolygon = new MultiPolygon(new Polygon[] { this.createPolygon(points, g.getFactory()) }, g.getFactory());
} else if (g instanceof MultiPolygon) {
geoMultiPolygon = (MultiPolygon) g;
} else if (g instanceof Polygon) {
geoMultiPolygon = new MultiPolygon(new Polygon[] { (Polygon) g }, g.getFactory());
} else if (g instanceof LineString) {
geoMultiPolygon = new MultiPolygon(new Polygon[] { this.createPolygon((LineString) g) }, g.getFactory());
} else if (g instanceof MultiLineString) {
MultiLineString mls = (MultiLineString) g;
Polygon[] polygons = new Polygon[mls.getNumGeometries()];
for (int n = 0; n < mls.getNumGeometries(); n++) {
polygons[n] = this.createPolygon((LineString) mls.getGeometryN(n));
}
geoMultiPolygon = new MultiPolygon(polygons, g.getFactory());
}
return geoMultiPolygon;
}
OGCWKBWriter.java 文件源码
项目:Java-OpenMobility
阅读 27
收藏 0
点赞 0
评论 0
/**
* Writes a {@link Geometry} to an {@link OutStream}.
*
* @param geom the geometry to write
* @param os the out stream to write to
* @throws IOException if an I/O error occurs
*/
public void write(Geometry geom, OutStream os) throws IOException {
if (geom instanceof Point)
writePoint((Point) geom, os);
// LinearRings will be written as LineStrings
else if (geom instanceof LineString)
writeLineString((LineString) geom, os);
else if (geom instanceof Polygon)
writePolygon((Polygon) geom, os);
else if (geom instanceof MultiPoint)
writeGeometryCollection(WKBConstants.wkbMultiPoint, (MultiPoint) geom, os);
else if (geom instanceof MultiLineString)
writeGeometryCollection(WKBConstants.wkbMultiLineString,
(MultiLineString) geom, os);
else if (geom instanceof MultiPolygon)
writeGeometryCollection(WKBConstants.wkbMultiPolygon,
(MultiPolygon) geom, os);
else if (geom instanceof GeometryCollection)
writeGeometryCollection(WKBConstants.wkbGeometryCollection,
(GeometryCollection) geom, os);
else {
Assert.shouldNeverReachHere("Unknown Geometry type");
}
}
InternalFeatureCollection.java 文件源码
项目:geomajas-project-server
阅读 25
收藏 0
点赞 0
评论 0
private Class getGeometryBinding(LayerType layerType) {
switch (layerType) {
case LINESTRING:
return Geometry.class;
case MULTILINESTRING:
return MultiLineString.class;
case MULTIPOINT:
return MultiPoint.class;
case MULTIPOLYGON:
return MultiPolygon.class;
case POINT:
return Point.class;
case POLYGON:
return Polygon.class;
default:
return Geometry.class;
}
}