/** */
public static Geometry flatten (GeometryCollection gc) {
final List<Point> points = new LinkedList<Point>();
final List<LineString> lines = new LinkedList<LineString>();
final List<Polygon> polygons = new LinkedList<Polygon>();
gc.apply(new GeometryFilter() {
public void filter (Geometry geom) {
if (geom instanceof Point) {
points.add((Point)geom);
} else if (geom instanceof LineString) {
lines.add((LineString)geom);
} else if (geom instanceof Polygon) {
polygons.add((Polygon)geom);
}
}
});
if (!polygons.isEmpty()) {
return gc.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
} else if (!lines.isEmpty()) {
return gc.getFactory().createMultiLineString(GeometryFactory.toLineStringArray(lines));
} else {
return gc.getFactory().createMultiPoint(GeometryFactory.toPointArray(points));
}
}
java类com.vividsolutions.jts.geom.GeometryFactory的实例源码
JTSUtil.java 文件源码
项目:sumo
阅读 28
收藏 0
点赞 0
评论 0
BlackBorderAnalysis.java 文件源码
项目:sumo
阅读 27
收藏 0
点赞 0
评论 0
/**
* check if the tile is on land
*
* @param top
* @param left
* @param bottom
* @param right
* @return
*/
public boolean checkIfTileIsOnLand(double top,double left,double bottom,double right){
boolean isOnLand=false;
if(land!=null){
GeometryFactory fact = new GeometryFactory();
Coordinate[] cs=new Coordinate[5];
cs[0]=new Coordinate(top, left);
cs[1]=new Coordinate(bottom, left);
cs[2]=new Coordinate(top,right);
cs[3]=new Coordinate(bottom,right);
cs[4]=new Coordinate(top,left);
Polygon tile=fact.createPolygon(cs);
for (Geometry p : land) {
if (p.contains(tile)) {
isOnLand=true;
break;
}
}
}
return isOnLand;
}
JTSUtil.java 文件源码
项目:sumo
阅读 28
收藏 0
点赞 0
评论 0
/**
*
* @param geom
* @return
*/
public static Geometry repair (Geometry geom) {
GeometryFactory factory = geom.getFactory();
if (geom instanceof MultiPolygon) {
MultiPolygon mp = (MultiPolygon)geom;
Polygon[] polys = new Polygon[mp.getNumGeometries()];
for (int i = 0; i < mp.getNumGeometries(); i += 1) {
polys[i] = repair((Polygon)mp.getGeometryN(i));
}
return factory.createMultiPolygon(polys);
} else if (geom instanceof Polygon) {
return repair((Polygon)geom);
} else if (geom.getGeometryType().equals("GeometryCollection")) {
GeometryCollection gc = (GeometryCollection)geom;
Geometry[] geoms = new Geometry[gc.getNumGeometries()];
for (int i = 0; i < gc.getNumGeometries(); i += 1) {
geoms[i] = repair(gc.getGeometryN(i));
}
Thread.dumpStack();
return factory.createGeometryCollection(geoms);
} else {
return(geom);
}
}
GeometryImage.java 文件源码
项目:sumo
阅读 38
收藏 0
点赞 0
评论 0
/**
*
* @param name
* @param type
* @param geoms
*/
public GeometryImage(String name,String type,List<Coordinate>geoms) {
this.type=type;
this.name=name;
this.geoms=new ArrayList<>();
//attsMap=new HashMap<>();
GeometryFactory gf = new GeometryFactory();
for(Coordinate c:geoms){
AttributesGeometry att = new AttributesGeometry(new String[]{"x","y"});
att.set("x",c.x);
att.set("y",c.y);
Geometry gg=gf.createPoint(c);
put(gg, att);
}
}
MaskVectorLayer.java 文件源码
项目:sumo
阅读 28
收藏 0
点赞 0
评论 0
/**
*
* @param imagePosition
* @param context
*/
public void mouseClicked(java.awt.Point imagePosition, OpenGLContext context) {
if(isEditable()){
this.selectedGeometry = null;
GeometryFactory gf = new GeometryFactory();
com.vividsolutions.jts.geom.Point p = gf.createPoint(new Coordinate(imagePosition.x, imagePosition.y));
for (Geometry temp : glayer.getGeometries()) {
if(temp instanceof Polygon){
Coordinate[] c=DistanceOp.nearestPoints(temp, p);
com.vividsolutions.jts.geom.Point nearest=gf.createPoint(c[0]);
if (nearest.isWithinDistance(temp,5 * context.getZoom())) {
this.selectedGeometry = temp;
System.out.println(""+temp.getCoordinate().x+","+temp.getCoordinate().y);
LayerPickedData.put(temp, glayer.getAttributes(temp));
break;
}
}
}
}
}
InterpolatedVectorLayer.java 文件源码
项目:sumo
阅读 44
收藏 0
点赞 0
评论 0
public Area getShape() {
Area maskArea = new Area();
Rectangle rect = new Rectangle(0, 0, reader.getWidth(), reader.getHeight());
GeometryFactory gf = new GeometryFactory();
Coordinate[] coords = new Coordinate[]{
new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
new Coordinate((int) rect.getMaxX(), (int) rect.getMinY()),
new Coordinate((int) rect.getMaxX(), (int) rect.getMaxY()),
new Coordinate((int) rect.getMinX(), (int) rect.getMaxY()),
new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
};
Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
for (Geometry p : glayer.getGeometries()) {
if (p.intersects(geom)) {
int[] xPoints = new int[p.getNumPoints()];
int[] yPoints = new int[p.getNumPoints()];
int i = 0;
for (Coordinate c : p.getCoordinates()) {
xPoints[i] = (int) (c.x);
yPoints[i++] = (int) (c.y);
}
maskArea.add(new Area(new java.awt.Polygon(xPoints, yPoints, p.getNumPoints())));
}
}
return maskArea;
}
BoundariesA0ShapefileTest.java 文件源码
项目:fpm
阅读 28
收藏 0
点赞 0
评论 0
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a0.shp")).thenReturn("src/test/resources/tomtom/boundaries/a0/andorra______________a0.shp");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{1.52185, 42.50760}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 0, 1, 7, point);
when(capitalProvider.get(0)).thenReturn(newArrayList(capital));
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10200000000008L)).thenReturn(of("name", "Andorra", "name:fr", "Andorre"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("andorra", 0)).thenReturn("2");
BoundariesA0Shapefile shapefile = new BoundariesA0Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a0.osm.pbf"));
}
BoundariesA2ShapefileTest.java 文件源码
项目:fpm
阅读 25
收藏 0
点赞 0
评论 0
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a2.shp")).thenReturn("src/test/resources/tomtom/boundaries/a2/belbe2___________a2.shp");
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10560000000838L)).thenReturn(of("name", "Leuven"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("belbe2", 2)).thenReturn("6");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.703077, 50.8756041}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 2, 1, 7, point);
when(capitalProvider.get(2)).thenReturn(newArrayList(capital));
BoundariesA2Shapefile shapefile = new BoundariesA2Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a2.osm.pbf"));
}
BoundariesA1ShapefileTest.java 文件源码
项目:fpm
阅读 26
收藏 0
点赞 0
评论 0
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a1.shp")).thenReturn("src/test/resources/tomtom/boundaries/a1/belgium______________a1.shp");
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10560000000843L)).thenReturn(of("name", "Brussel", "name:fr", "Bruxelles"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("belgium", 1)).thenReturn("4");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.868077, 50.4536041}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 1, 1, 7, point);
when(capitalProvider.get(1)).thenReturn(newArrayList(capital));
BoundariesA1Shapefile shapefile = new BoundariesA1Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a1.osm.pbf"));
}
GeometryValidator.java 文件源码
项目:sig-seguimiento-vehiculos
阅读 24
收藏 0
点赞 0
评论 0
private boolean validateMinSegmentLength(final Geometry geom, final Coordinate... coordinates) {
boolean isValid = true;
if (coordinates.length >= 2) {
for (int i = 1; i < coordinates.length; i++) {
if (!validateMinSegmentLength(coordinates[i - 1],
coordinates[i])) {
GeometryFactory geomFactory = new GeometryFactory();
errorCoordinates.add(geomFactory
.createPoint(coordinates[i]).toText());
isValid = false;
}
}
}
return isValid;
}
MvtReader.java 文件源码
项目:vt-support
阅读 31
收藏 0
点赞 0
评论 0
private static Geometry readGeometry(List<Integer> geomCmds,
VectorTile.Tile.GeomType geomType,
GeometryFactory geomFactory,
Vec2d cursor,
RingClassifier ringClassifier) {
Geometry result = null;
switch (geomType) {
case POINT:
result = readPoints(geomFactory, geomCmds, cursor);
break;
case LINESTRING:
result = readLines(geomFactory, geomCmds, cursor);
break;
case POLYGON:
result = readPolys(geomFactory, geomCmds, cursor, ringClassifier);
break;
default:
LoggerFactory.getLogger(MvtReader.class)
.error("readGeometry(): Unhandled geometry type [{}]", geomType);
}
return result;
}
TestReedsSheppCarPlannerSmoothGeometry.java 文件源码
项目:coordination_oru
阅读 24
收藏 0
点赞 0
评论 0
public static void main(String[] args) {
ReedsSheppCarPlanner rsp = new ReedsSheppCarPlanner();
Coordinate footprint1 = new Coordinate(-2.0,0.5);
Coordinate footprint2 = new Coordinate(2.0,0.5);
Coordinate footprint3 = new Coordinate(2.0,-0.5);
Coordinate footprint4 = new Coordinate(-2.0,-0.5);
rsp.setRadius(0.5);
rsp.setFootprint(footprint1,footprint2,footprint3,footprint4);
JTSDrawingPanel panel = JTSDrawingPanel.makeEmpty("debug");
GeometryFactory gf = new GeometryFactory();
Polygon footprint = gf.createPolygon(new Coordinate[] {footprint1,footprint2,footprint3,footprint4,footprint1});
Polygon smoothedFootprint = gf.createPolygon(rsp.getCollisionCircleCenters());
System.out.println("Smoothing went from " + footprint.getCoordinates().length + " to " + smoothedFootprint.getCoordinates().length + " points");
panel.addGeometry("orig", footprint, true, true, true, "#00FF00");
panel.addGeometry("smooth", smoothedFootprint, false, false, true, "#FF0000");
for (int i = 0; i < smoothedFootprint.getCoordinates().length; i++) {
double delta = 0.1;
Coordinate p1 = new Coordinate(smoothedFootprint.getCoordinates()[i].x,smoothedFootprint.getCoordinates()[i].y);
Coordinate p2 = new Coordinate(smoothedFootprint.getCoordinates()[i].x+delta,smoothedFootprint.getCoordinates()[i].y+delta);
Coordinate p3 = new Coordinate(smoothedFootprint.getCoordinates()[i].x-delta,smoothedFootprint.getCoordinates()[i].y+delta);
panel.addGeometry("_cp"+i, gf.createPolygon(new Coordinate[] {p1,p2,p3,p1}), false, false, false, "#000000");
}
}
PathEditor.java 文件源码
项目:coordination_oru
阅读 45
收藏 0
点赞 0
评论 0
private Geometry makeObstacle(Pose p) {
GeometryFactory gf = new GeometryFactory();
Geometry geom = null;
if (obstacleFootprint == null) {
geom = gf.createPolygon(new Coordinate[] { new Coordinate(0.0,0.0), new Coordinate(0.0,OBSTACLE_SIZE), new Coordinate(OBSTACLE_SIZE,OBSTACLE_SIZE), new Coordinate(OBSTACLE_SIZE,0.0), new Coordinate(0.0,0.0) });
}
else {
geom = gf.createPolygon(obstacleFootprint);
}
AffineTransformation at = new AffineTransformation();
at.rotate(p.getTheta());
at.translate(p.getX(), p.getY());
Geometry transGeom = at.transform(geom);
Pose center = new Pose(p.getX(), p.getY(), p.getTheta());
obstacles.add(transGeom);
obstacleCenters.add(center);
return transGeom;
}
TestSpatial.java 文件源码
项目:ThriftyPaxos
阅读 26
收藏 0
点赞 0
评论 0
/**
* Generate a random line string under the given bounding box.
*
* @param geometryRand the random generator
* @param minX Bounding box min x
* @param maxX Bounding box max x
* @param minY Bounding box min y
* @param maxY Bounding box max y
* @param maxLength LineString maximum length
* @return A segment within this bounding box
*/
static Geometry getRandomGeometry(Random geometryRand,
double minX, double maxX,
double minY, double maxY, double maxLength) {
GeometryFactory factory = new GeometryFactory();
// Create the start point
Coordinate start = new Coordinate(
geometryRand.nextDouble() * (maxX - minX) + minX,
geometryRand.nextDouble() * (maxY - minY) + minY);
// Compute an angle
double angle = geometryRand.nextDouble() * Math.PI * 2;
// Compute length
double length = geometryRand.nextDouble() * maxLength;
// Compute end point
Coordinate end = new Coordinate(
start.x + Math.cos(angle) * length,
start.y + Math.sin(angle) * length);
return factory.createLineString(new Coordinate[] { start, end });
}
GISUtils.java 文件源码
项目:oma-riista-web
阅读 26
收藏 0
点赞 0
评论 0
private static Geometry unionTree(final List<?> tree) {
final ArrayList<Geometry> geomList = new ArrayList<>(16);
// Do not use Stream to conserve memory!
for (final Object o : tree) {
if (o instanceof List) {
geomList.add(unionTree((List) o));
} else if (o instanceof Geometry) {
geomList.add((Geometry) o);
}
if (Thread.currentThread().isInterrupted()) {
throw new RuntimeException("Processing was interrupted");
}
}
final GeometryFactory factory = geomList.get(0).getFactory();
return factory.buildGeometry(geomList).buffer(0);
}
GeneralCSVImporter.java 文件源码
项目:TomboloDigitalConnector
阅读 28
收藏 0
点赞 0
评论 0
private Geometry getShape(CSVRecord record) {
if (!config.getGeographyProjection().equals("") &&
config.getGeographyXIndex() != -1 &&
config.getGeographyYIndex() != -1) {
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), Subject.SRID);
Coordinate coordinate = null;
Double x = Double.parseDouble(record.get(config.getGeographyXIndex()));
Double y = Double.parseDouble(record.get(config.getGeographyYIndex()));
if (config.getGeographyProjection().equals(CoordinateUtils.WGS84CRS)) {
coordinate = new Coordinate(x, y);
} else {
try {
coordinate = CoordinateUtils.eastNorthToLatLong(x, y, config.getGeographyProjection(), CoordinateUtils.WGS84CRS);
} catch (Exception e) {
log.warn("Coordinates will not be considered: " + e.getMessage());
return null;
}
}
return geometryFactory.createPoint(coordinate);
}
return null;
}
GeometryEditor.java 文件源码
项目:Earth
阅读 25
收藏 0
点赞 0
评论 0
@Override
public final Geometry edit(Geometry geometry, GeometryFactory factory) {
if (geometry instanceof LinearRing) {
return factory.createLinearRing(this.edit(
((LinearRing) geometry).getCoordinateSequence(),
geometry));
}
if (geometry instanceof LineString) {
return factory.createLineString(this.edit(
((LineString) geometry).getCoordinateSequence(),
geometry));
}
if (geometry instanceof Point) {
return factory.createPoint(this.edit(
((Point) geometry).getCoordinateSequence(),
geometry));
}
return geometry;
}
MesureOrientationFeuille.java 文件源码
项目:geoxygene
阅读 22
收藏 0
点赞 0
评论 0
/**
* Constructeur de mesure d'orientation à partir d'une géométrie geoxygene.
* @param geomGeox géométrie sur laquelle on va calculer l'orientation.
* @param angleMaximum angle correspondant à la borne supérieure de l'intervalle
* dans lequel doit être réalisé le calcul (valeur attendue : pi pour les polygones
* et pi/2 pour les côtés des polygones).
*/
public MesureOrientationFeuille(IGeometry geomGeox,double angleMaximum){
listeOrientations = new ArrayList<Double> ();
listePoids = new ArrayList<Double> ();
try {
Geometry geom=AdapterFactory.toGeometry(new GeometryFactory(), geomGeox);
if (geom instanceof Polygon) {
Polygon poly = (Polygon)geom;
LineString contourExterieur = poly.getExteriorRing();
ajouterOrientation(contourExterieur);
for (int i=0;i<poly.getNumInteriorRing();i++){
LineString contourInterieur = poly.getInteriorRingN(i);
ajouterOrientation(contourInterieur);
}
}
else {
logger.error("La géométrie entrée n'est pas un polygone");
return;
}
}
catch (Exception e) {e.printStackTrace();}
this.angleMaximum = angleMaximum;
nbOrientationsTestees = (int) (angleMaximum / ANGLE_PRECISION);
}
GeodatabaseHibernate.java 文件源码
项目:geoxygene
阅读 28
收藏 0
点赞 0
评论 0
@Override
public <T extends IFeature> IFeatureCollection<T> loadAllFeatures(Class<T> featureClass, IGeometry geom) {
Criteria criteria = session.createCriteria(featureClass);
try {
criteria.add(
SpatialRestrictions.intersects("geom", AdapterFactory.toGeometry(new GeometryFactory(), geom))); //$NON-NLS-1$
FT_FeatureCollection<T> result = new FT_FeatureCollection<T>();
List<?> list = criteria.list();
for (Object o : list) {
result.add((T) o);
}
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
GeometryTransformer.java 文件源码
项目:Earth
阅读 33
收藏 0
点赞 0
评论 0
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = this.transform(geom.getGeometryN(i));
if (transformGeom == null) {
continue;
}
if (this.pruneEmptyGeometry && transformGeom.isEmpty()) {
continue;
}
transGeomList.add(transformGeom);
}
if (this.preserveGeometryCollectionType) {
return this.factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));
}
return this.factory.buildGeometry(transGeomList);
}
JtsUtil.java 文件源码
项目:geoxygene
阅读 31
收藏 0
点赞 0
评论 0
/**
* Calcul de la fermeture d'un polygone.
* @param polygon polygone de départ
* @param distance distance utilisée pour le buffer positif puis pour le buffer négatif
* @param distanceTolerance distance utilisée pour la simplification par l'algorithme de Douglas-Peucker
* @param quadrantSegments nombre de segments utilisés pour la simplification par l'algorithme de Douglas-Peucker
* @param endCapStyle type d'approximation utilisée pour la simplification par l'algorithme de Douglas-Peucker
* @param factory factory pour la géométrie
* @return la fermeture du polygone passé en paramètre
*/
public static Polygon fermeture(Polygon polygon,double distance,double distanceTolerance,int quadrantSegments,int endCapStyle,GeometryFactory factory) {
LinearRing exterior = (LinearRing) polygon.getExteriorRing();
Geometry boundary = factory.createPolygon(exterior, null);
Polygon result = null;
try{
boundary = boundary.buffer(distance,quadrantSegments,endCapStyle);
boundary = boundary.buffer(-distance,quadrantSegments,endCapStyle);
if (boundary.isEmpty()) return polygon;
result = (Polygon)JtsAlgorithms.filtreDouglasPeucker(boundary,distanceTolerance);
} catch (Exception e) {
logger.error(polygon.toText());
logger.error(boundary.toText());
e.printStackTrace();
}
return result;
}
AdapterFactory.java 文件源码
项目:geoxygene
阅读 36
收藏 0
点赞 0
评论 0
/**
* Transforme une liste de {@link GM_Ring}s GeOxygene en {@link LinearRing}s
* JTS
* @param factory factory JTS
* @param list liste de {@link GM_Ring}s
* @return tableau de {@link LinearRing}s JTS équivalents
* @throws Exception renvoie une exception si le type de géométrie n'est pas
* géré.
*/
public static LinearRing[] toLinearRingArray(GeometryFactory factory,
List<IRing> list) throws Exception {
// LinearRing[] rings = new LinearRing[list.size()];
List<LinearRing> rings = new ArrayList<LinearRing>();
for (int i = 0; i < list.size(); i++) {
LinearRing ring = (LinearRing) AdapterFactory.toGeometry(factory,
list.get(i));
if (ring != null) {
rings.add(ring);
} else {
return null;
}
}
return rings.toArray(new LinearRing[0]);
}
GeometryEditor.java 文件源码
项目:Earth
阅读 28
收藏 0
点赞 0
评论 0
@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;
}
QuadEdgeSubdivision.java 文件源码
项目:Earth
阅读 29
收藏 0
点赞 0
评论 0
/**
* Gets a List of {@link Polygon}s for the Voronoi cells
* of this triangulation.
* <p>
* The userData of each polygon is set to be the {@link Coordinate}
* of the cell site. This allows easily associating external
* data associated with the sites to the cells.
*
* @param geomFact a geometry factory
* @return a List of Polygons
*/
public List getVoronoiCellPolygons(GeometryFactory geomFact) {
/*
* Compute circumcentres of triangles as vertices for dual edges.
* Precomputing the circumcentres is more efficient,
* and more importantly ensures that the computed centres
* are consistent across the Voronoi cells.
*/
this.visitTriangles(new TriangleCircumcentreVisitor(), true);
List cells = new ArrayList();
Collection edges = this.getVertexUniqueEdges(false);
for (Object edge : edges) {
QuadEdge qe = (QuadEdge) edge;
cells.add(this.getVoronoiCellPolygon(qe, geomFact));
}
return cells;
}
UserMapper.java 文件源码
项目:C4SG-Obsolete
阅读 30
收藏 0
点赞 0
评论 0
/**
* Map user data transfer object into user entity
*
* @param userDTO User Data Transfer object
* @return User
*/
public User getUserEntityFromDto(UserDTO userDTO){
User user = map(userDTO, User.class);
if (userDTO.getLatitude() != null && userDTO.getLongitude() != null){
GeometryFactory gf = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
Coordinate coordinate = new Coordinate(Double.parseDouble(userDTO.getLongitude()),
Double.parseDouble(userDTO.getLatitude()));
com.vividsolutions.jts.geom.Point point = gf.createPoint(coordinate);
user.setLocation(point);
}
user.setDisplayFlag(Boolean.valueOf(userDTO.getDisplayFlag()));
return user;
}
Ambiguity.java 文件源码
项目:sumo
阅读 31
收藏 0
点赞 0
评论 0
/**
* get a List of geometry: each geometry is an ambiguity boat
*
* @return List of the geometry for the ambiguity boats
*/
public List<Geometry> getAmbiguityboatgeometry() {
List<Geometry> out = new ArrayList<Geometry>();
GeometryFactory gf = new GeometryFactory();
//loop on ambigutiy boat
for (int i = 0; i < ambiguityboatlist.size(); i++) {
Boat boat = ambiguityboatlist.get(i);
out.add(gf.createPoint(new Coordinate(boat.getPosx(), boat.getPosy())));
}
return out;
}
DetectedPixels.java 文件源码
项目:sumo
阅读 25
收藏 0
点赞 0
评论 0
/**
*
* @return
*/
public List<Geometry> getAllDetectedPixels() {
List<Geometry> out = new ArrayList<Geometry>();
GeometryFactory gf = new GeometryFactory();
BoatPixel[] enumeration = allDetectedPixels.toArray(new BoatPixel[0]);
for (BoatPixel pixel : enumeration) {
out.add(gf.createPoint(new Coordinate(pixel.x, pixel.y)));
}
return out;
}
DetectedPixels.java 文件源码
项目:sumo
阅读 25
收藏 0
点赞 0
评论 0
public List<Geometry> getThresholdclipPixels() {
List<Geometry> out = new ArrayList<Geometry>();
GeometryFactory gf = new GeometryFactory();
for (BoatConnectedPixelMap boat : listboatneighbours) {
List<int[]> positions = boat.getThresholdclipPixels();
for (int[] position : positions) {
out.add(gf.createPoint(new Coordinate(position[0], position[1])));
}
}
return out;
}
DetectedPixels.java 文件源码
项目:sumo
阅读 21
收藏 0
点赞 0
评论 0
public List<Geometry> getThresholdaggregatePixels() {
List<Geometry> out = new ArrayList<Geometry>();
GeometryFactory gf = new GeometryFactory();
for (BoatConnectedPixelMap boat : listboatneighbours) {
List<int[]> positions = boat.getThresholdaggregatePixels();
for (int[] position : positions) {
out.add(gf.createPoint(new Coordinate(position[0], position[1])));
}
}
return out;
}
MaskGeometries.java 文件源码
项目:sumo
阅读 30
收藏 0
点赞 0
评论 0
public boolean contains(int x, int y) {
GeometryFactory gf = new GeometryFactory();
Point geom = gf.createPoint(new Coordinate(x, y));
for (Geometry p : maskGeometries) {
if (p.contains(geom)) {
return true;
}
}
return false;
}