本文整理汇总了Java中org.geotools.geometry.jts.JTSFactoryFinder类的典型用法代码示例。如果您正苦于以下问题:Java JTSFactoryFinder类的具体用法?Java JTSFactoryFinder怎么用?Java JTSFactoryFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JTSFactoryFinder类属于org.geotools.geometry.jts包,在下文中一共展示了JTSFactoryFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
/**
* Query the polygons in our geography to find the country of the input coordinate.
* @param coordinate the coordinate that needs to be queried.
* @return the name of the coordinate state or UNKNOWN if not found.
*/
public String query(Coordinate coordinate) {
final Point point = JTSFactoryFinder.getGeometryFactory().createPoint(coordinate);
/** Before trying to locate the country,
* we make sure that the point lies within
* the specified bounding box.
*/
if (!Geography.isInsideEnvelope(point)) {
return UNKNOWN_COUNTRY;
}
for (Map.Entry<String, MultiPolygon> entry : this.polygons) {
if (entry.getValue().contains(point)) {
return entry.getKey();
}
}
return UNKNOWN_COUNTRY;
}
示例2: testEnvelopeBox
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
/**
* Test the envelope box containment.
*/
public void testEnvelopeBox() {
final Point point = JTSFactoryFinder.getGeometryFactory().createPoint(new Coordinate());
point.getCoordinate().setOrdinate(0, -83.17);
point.getCoordinate().setOrdinate(1, 30.87);
point.geometryChanged();
assertTrue(Geography.isInsideEnvelope(point));
point.getCoordinate().setOrdinate(0, -118.13);
point.getCoordinate().setOrdinate(1, 33.90);
point.geometryChanged();
assertTrue(Geography.isInsideEnvelope(point));
point.getCoordinate().setOrdinate(0, 0);
point.getCoordinate().setOrdinate(1, 0);
point.geometryChanged();
assertFalse(Geography.isInsideEnvelope(point));
point.getCoordinate().setOrdinate(0, 11.05);
point.getCoordinate().setOrdinate(1, 47.57);
point.geometryChanged();
assertFalse(Geography.isInsideEnvelope(point));
}
示例3: snapPointTest
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
@Test
public void snapPointTest() {
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
Coordinate coord1 = new Coordinate(89.37412487,110.2487538);
Coordinate coord2 = new Coordinate(125.76543268795456, 130.0001458);
Coordinate coord3 = new Coordinate(100.02458, 119.88754);
LineString line = gf.createLineString(new Coordinate[]{coord1, coord2});
Point point = gf.createPoint(coord3);
Point snapPoint = JTSUtil.snapPointToLineStringByLIL(line, point);
System.out.println(snapPoint.toText());
Double a = 5.00000;
String str = String.valueOf(a);
System.out.println(str);
System.out.println("test");
}
示例4: createExtraFeatures
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
private static Layer createExtraFeatures() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("Location");
b.setCRS(DefaultGeographicCRS.WGS84);
// picture location
b.add("geom", Point.class);
final SimpleFeatureType TYPE = b.buildFeatureType();
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
Point point = gf.createPoint(new Coordinate(CANBERRA_LONG, CANBERRA_LAT));
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(TYPE);
builder.add(point);
SimpleFeature feature = builder.buildFeature("Canberra");
DefaultFeatureCollection features = new DefaultFeatureCollection(null, null);
features.add(feature);
Style style = SLD.createPointStyle("Star", Color.BLUE, Color.BLUE, 0.3f, 10);
return new FeatureLayer(features, style);
}
示例5: javaFlag
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public void javaFlag() {
// javaFlag start
class Flag {
public Point location;
public String name;
public int classification;
public double height;
};
GeometryFactory geomFactory = JTSFactoryFinder.getGeometryFactory();
Flag here = new Flag();
here.location = geomFactory.createPoint( new Coordinate(23.3,-37.2) );
here.name = "Here";
here.classification = 3;
here.height = 2.0;
// javaFlag end
}
示例6: featureFlag
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public void featureFlag() {
// featureFlag start
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName( "Flag" );
b.setCRS( DefaultGeographicCRS.WGS84 );
b.add( "location", Point.class );
b.add( "name", String.class );
b.add( "classification", Integer.class );
b.add( "height", Double.class );
SimpleFeatureType type = b.buildFeatureType();
GeometryFactory geomFactory = JTSFactoryFinder.getGeometryFactory();
SimpleFeatureBuilder f = new SimpleFeatureBuilder( type );
f.add( geomFactory.createPoint( new Coordinate(23.3,-37.2) ) );
f.add("here");
f.add(3);
f.add(2.0);
SimpleFeature feature = f.buildFeature("fid.1");
// featureFlag end
}
示例7: getPolygon
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的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;
}
示例8: getLine
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
@Override
public LineString getLine() {
if (line == null) {
//CHECKSTYLE:OFF
double[][] rawLocations = new double[][] { { -123.167725, 48.502048 },
{ -123.464355, 48.297812 }, { -124.738770, 48.603858 },
{ -125.189209, 48.828566 }, { -125.112305, 48.951366 },
{ -125.507812, 48.929718 }, { -125.870361, 49.145784 },
{ -126.035156, 49.167339 }, { -126.112061, 49.253465 },
{ -126.243896, 49.282140 }, { -126.287842, 49.360912 },
{ -126.397705, 49.410973 }, { -126.573486, 49.375220 },
{ -126.584473, 49.560852 }, { -126.815186, 49.610710 },
{ -127.012939, 49.745781 }, { -126.947021, 49.788357 },
{ -127.166748, 49.852152 }, { -127.518311, 50.113533 },
{ -127.814941, 50.078295 }, { -127.957764, 50.120578 },
{ -127.825928, 50.254230 }, { -128.012695, 50.331436 },
{ -127.946777, 50.450509 }, { -128.122559, 50.457504 },
{ -128.364258, 50.652943 }, { -128.342285, 50.792047 },
{ -128.100586, 50.882243 }, { -127.858887, 50.944584 },
{ -127.518311, 50.798991 }, { -127.221680, 50.639010 } };
//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++;
}
line = geometryFactory.createLineString(coords);
}
return line;
}
示例9: openInputShapefile
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
/**
* Open the input shape file and load it into memory.
*/
public void openInputShapefile(String inputShapefile) throws IOException {
File file = new File(inputShapefile);
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
Map<String, Serializable> params = new HashMap<>();
params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.ENABLE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.CACHE_MEMORY_MAPS.key, Boolean.TRUE);
ShapefileDataStore store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
featureSource = store.getFeatureSource();
// determine the correct case of the tz attribute because its case has been
// changed from efele to evansiroky
SimpleFeatureType schema = featureSource.getSchema();
List<AttributeDescriptor> attributeDescriptorList = schema.getAttributeDescriptors();
for (AttributeDescriptor attributeDescriptor : attributeDescriptorList) {
if ("tzid".equalsIgnoreCase(attributeDescriptor.getLocalName())) {
tzidAttr = attributeDescriptor.getLocalName();
}
}
filterFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
geometryFactory = JTSFactoryFinder.getGeometryFactory();
}
示例10: read
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public void read(File wktFile) {
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
WKTReader wktReader = new WKTReader(gf);
FileReader fr = null;
BufferedReader fileReader = null;
try {
fr = new FileReader(wktFile);
fileReader = new BufferedReader(fr);
while(true) {
String line = fileReader.readLine();
if(line == null) break;
//com.vividsolutions.jts.geom.MultiPolygon multiPolygon = (com.vividsolutions.jts.geom.MultiPolygon) wktReader.read(line);
com.vividsolutions.jts.geom.Polygon polygon = (com.vividsolutions.jts.geom.Polygon) wktReader.read(line);
double counterClockwised = JTSUtil.Orientation2D_Polygon(polygon.getCoordinates().length, polygon.getExteriorRing().getCoordinateSequence());
if(counterClockwised > 0) {
polygon = (com.vividsolutions.jts.geom.Polygon) polygon.reverse();
}
com.vividsolutions.jts.geom.Polygon transformation = (com.vividsolutions.jts.geom.Polygon) transformation(polygon);
Polygon geometry2D = getIndoorGMLGeometry(transformation);
geometry2D = removeDuplicatePoint(geometry2D);
if(geometry2D != null)
createCellSpace(geometry2D);
}
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例11: main
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public static void main(String[] args) {
Coordinate[] coords = new Coordinate[] {new Coordinate(0, 0), new Coordinate(2, 2), new Coordinate(2, 2), new Coordinate(0, 2), new Coordinate(0, 0)};
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
LineString exterior = geometryFactory.createLineString(coords);
Polygon polygon = geometryFactory.createPolygon(coords);
System.out.println("exterior : " + exterior.isValid());
System.out.println("polygon : " + polygon.isValid());
}
示例12: transformTest
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public static void transformTest() {
/*
* 37.5116785 127.1021436
*
* 37.5119898 127.1025482
*
* 37.5134122 127.1025103
*/
/*
*
*/
Coordinate coord1 = new Coordinate(0.14195979899497488, 0.056451612903225756);
Coordinate coord2 = new Coordinate(0.44597989949748745, 0.1088709677419355);
Coordinate coord3 = new Coordinate(0.9849246231155779, 0.9905913978494624);
Coordinate coord4 = new Coordinate(37.5116785, 127.1021436);
Coordinate coord5 = new Coordinate(37.5119898, 127.1025482);
Coordinate coord6 = new Coordinate(37.5134122, 127.1025103);
Coordinate test = new Coordinate(0.9510050251256281, 0.728494623655914);
Point p = JTSFactoryFinder.getGeometryFactory().createPoint(test);
AffineTransformation affine = new AffineTransformationBuilder(coord1, coord2, coord3,
coord4, coord5, coord6).getTransformation();
Geometry geom = affine.transform(p);
System.out.println(geom.toText());
}
示例13: wktTest
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
public static void wktTest() {
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
WKTReader reader = new WKTReader(geometryFactory);
try {
Polygon polygon = (Polygon) reader.read("POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))");
MultiPolygon multiPolygon = geometryFactory.createMultiPolygon(new Polygon[]{polygon});
System.out.println(multiPolygon.toText());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例14: updateLocation
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
private void updateLocation() {
if(this.decimalLatitude != null && this.decimalLongitude != null) {
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
this.location = geometryFactory.createPoint(new Coordinate(this.decimalLongitude, this.decimalLatitude));
} else {
this.location = null;
}
}
示例15: updateLocation
import org.geotools.geometry.jts.JTSFactoryFinder; //导入依赖的package包/类
private void updateLocation() {
if(this.latitude != null && this.longitude != null) {
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
this.location = geometryFactory.createPoint(new Coordinate(this.longitude, this.latitude));
} else {
this.location = null;
}
}