本文整理匯總了Java中com.vividsolutions.jts.geom.PrecisionModel.FLOATING屬性的典型用法代碼示例。如果您正苦於以下問題:Java PrecisionModel.FLOATING屬性的具體用法?Java PrecisionModel.FLOATING怎麽用?Java PrecisionModel.FLOATING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.vividsolutions.jts.geom.PrecisionModel
的用法示例。
在下文中一共展示了PrecisionModel.FLOATING屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getUserEntityFromDto
/**
* 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;
}
示例2: GISExtensionState
/** */
public GISExtensionState (org.nlogo.api.ExtensionManager em) {
_em = (ExtensionManager)em;
_factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
_projection = null;
_datasetCount = 0;
_transformation = null;
setNetLogoColor(org.nlogo.api.Color.BoxedBlack());
_coverageSingleCellThreshold = 0.1;
_coverageMultipleCellThreshold = 0.33;
}
示例3: projectGeometry
/**
* Project geometry.
*
* @param originalGeom
* the original geom
* @param srcCRSCode
* the src crs code
* @param trgCRSCode
* the trg crs code
* @return the geometry
* @throws NoSuchAuthorityCodeException
* the no such authority code exception
* @throws FactoryException
* the factory exception
* @throws MismatchedDimensionException
* the mismatched dimension exception
* @throws TransformException
* the transform exception
*/
public static Geometry projectGeometry(Geometry originalGeom, String srcCRSCode,
String trgCRSCode) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException,
TransformException
{
Geometry projectedGeometry = null;
final MathTransform transform = CRS.findMathTransform(CRS.decode(srcCRSCode, true), CRS.decode(trgCRSCode, true), true);
// converting geometries into a linear system
try
{
projectedGeometry = JTS.transform(originalGeom, transform);
}
catch (Exception e)
{
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(
PrecisionModel.FLOATING), 4326);
WKTReader reader = new WKTReader(geometryFactory);
try
{
Polygon worldCutPolygon = (Polygon) reader.read("POLYGON((-180 -89.9, -180 89.9, 180 89.9, 180 -89.9, -180 -89.9))");
projectedGeometry = JTS.transform(originalGeom.intersection(worldCutPolygon),
transform);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
return projectedGeometry;
}
示例4: getAuthorizedArea
protected Geometry getAuthorizedArea(String layerId) {
if (null == biggestGeometry) {
// build Geometry which covers biggest possible area
Envelope maxBounds = new Envelope(-Float.MAX_VALUE, Float.MAX_VALUE, -Float.MAX_VALUE, Float.MAX_VALUE);
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
biggestGeometry = geometryFactory.toGeometry(maxBounds);
}
return biggestGeometry;
}
示例5: areaCombine
private Geometry areaCombine(String layerId, AreaCombineGetter areaGetter) {
if (null == authentications || authentications.size() == 0) {
// no authorizations, so nothing should be allowed
return null;
}
Layer<?> layer = configurationService.getLayer(layerId);
if (null == layer) {
log.error("areaCombine on unknown layer " + layerId);
return null;
}
LayerInfo layerInfo = layer.getLayerInfo();
// base is the max bounds of the layer
Envelope maxBounds = converterService.toInternal(layerInfo.getMaxExtent());
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
int srid = geoService.getSridFromCrs(layer.getLayerInfo().getCrs());
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, srid);
Geometry geometry = geometryFactory.toGeometry(maxBounds);
// limit based on authorizations
for (Authentication authentication : authentications) {
for (BaseAuthorization authorization : authentication.getAuthorizations()) {
if (authorization instanceof AreaAuthorization) {
geometry = geometry.intersection(areaGetter.get((AreaAuthorization) authorization));
}
}
}
geometry.setSRID(srid); // force srid, even when not set correctly by security service
return geometry;
}
示例6: testDefaultVisibleArea
@Test
public void testDefaultVisibleArea() throws Exception {
DefaultSecurityContext securityContext = (DefaultSecurityContext)this.securityContext;
List<Authentication> authentications = new ArrayList<Authentication>();
Authentication auth1 = getBaseAuthentication();
authentications.add(auth1);
securityContext.setAuthentications("token", authentications);
Assert.assertTrue(securityContext.isLayerVisible(LAYER_ID));
Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
Assert.assertNotNull(geometry);
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
Coordinate coordinate = new Coordinate();
coordinate.x = coordinate.y = -86;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = -85.05;
coordinate.y = -85.05;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = -85.05;
coordinate.y = 85.05;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = 85.05;
coordinate.y = -85.05;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = 85.05;
coordinate.y = 85.05;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 86;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
}
示例7: testDefaultVisibleAreaOne
@Test
public void testDefaultVisibleAreaOne() throws Exception {
DefaultSecurityContext securityContext = (DefaultSecurityContext)this.securityContext;
List<Authentication> authentications = new ArrayList<Authentication>();
Authentication auth1 = getAuthentication();
Authentication auth2 = getAreaAuthentication(1);
authentications.add(auth1);
authentications.add(auth2);
securityContext.setAuthentications("token", authentications);
Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
Assert.assertNotNull(geometry);
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
Coordinate coordinate = new Coordinate();
coordinate.x = coordinate.y = 0.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 1.5;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 2.5;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 3.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 4.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
}
示例8: testDefaultVisibleAreaTwo
@Test
public void testDefaultVisibleAreaTwo() throws Exception {
DefaultSecurityContext securityContext = (DefaultSecurityContext)this.securityContext;
List<Authentication> authentications = new ArrayList<Authentication>();
Authentication auth1 = getAreaAuthentication(1);
Authentication auth2 = getAreaAuthentication(2);
authentications.add(auth1);
authentications.add(auth2);
securityContext.setAuthentications("token", authentications);
Geometry geometry = securityContext.getVisibleArea(LAYER_ID);
Assert.assertNotNull(geometry);
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
Coordinate coordinate = new Coordinate();
coordinate.x = coordinate.y = 0.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 1.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 2.5;
Assert.assertTrue(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 3.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
coordinate.x = coordinate.y = 4.5;
Assert.assertFalse(geometry.contains(geometryFactory.createPoint(coordinate)));
Assert.assertFalse(securityContext.isPartlyVisibleSufficient(LAYER_ID));
}
示例9: TestAuthorization
public TestAuthorization(int which) {
Envelope envelope;
if (1 == which) {
partly = false;
envelope = new Envelope(1, 3, 1, 3);
} else {
partly = true;
envelope = new Envelope(2, 4, 2, 4);
}
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, LAYER_SRID);
geometry = geometryFactory.toGeometry(envelope);
}
示例10: getAuthorizedArea
protected Geometry getAuthorizedArea(String layerId) {
if (null == biggestGeometry) {
// build Geometry which covers biggest possible area
Envelope maxBounds = new Envelope(-Double.MAX_VALUE, Double.MAX_VALUE,
-Double.MAX_VALUE, Double.MAX_VALUE);
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
biggestGeometry = geometryFactory.toGeometry(maxBounds);
}
return biggestGeometry;
}
示例11: setupBeans
@Before
public void setupBeans() throws LayerException {
GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4329);
LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0),
new Coordinate(1, 1), new Coordinate(0, 1), new Coordinate(0, 0), });
Polygon p = factory.createPolygon(shell, null);
MultiPolygon expected = factory.createMultiPolygon(new Polygon[] { p });
CustomBean cb = new CustomBean();
cb.setId(1);
cb.setGeometry(expected);
cb.setName("testbean");
layer.saveOrUpdate(cb);
}
示例12: createFeatureCollectionFromCsv
/**
* Helper method creating feature collection
* @param featureTypeDefinition {@link SimpleFeatureType} of provided features
* @param retVals {@link HashMap} representing features
* @return {@link SimpleFeatureCollection} feature collection
*/
private SimpleFeatureCollection createFeatureCollectionFromCsv(SimpleFeatureType featureTypeDefinition, HashMap<String, HashMap<String, String>> retVals) {
ArrayList<SimpleFeature> featureList = new ArrayList<SimpleFeature>();
PrecisionModel precModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geomFactory = new GeometryFactory(precModel);
long internalId = 1;
for (String key : retVals.keySet()) {
String x = null, y = null;
HashMap<String, String> geoObject = retVals.get(key);
x = geoObject.get(NAME_OF_ABSCISSA.toLowerCase());
y = geoObject.get(NAME_OF_ORDINATE.toLowerCase());
if (StringUtils.isBlank(x) || StringUtils.isBlank(y)) {
LOG.warn("Object " + geoObject + " will be ignored from import since one/more coordinate(s) are empty.");
continue;
}
double xVal = Double.NaN, yVal = Double.NaN;
try {
xVal = Double.parseDouble(x);
yVal = Double.parseDouble(y);
} catch (NumberFormatException nfe) {
LOG.warn("Object " + geoObject
+ " will be ignored from import since one/more cordinates don't contain numerical values.");
continue;
}
Point pt = geomFactory.createPoint(new Coordinate(xVal, yVal));
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureTypeDefinition);
// Iterate over featureType
List<AttributeDescriptor> attrDescrList = featureTypeDefinition.getAttributeDescriptors();
for (AttributeDescriptor attrDesc : attrDescrList){
Name attributeName = attrDesc.getName();
if ( attributeName.getLocalPart().equalsIgnoreCase(NAME_OF_GEOMETRY) ){
featureBuilder.add(pt);
}else{
String attrVal = geoObject.get(attributeName.getLocalPart().toLowerCase());
featureBuilder.add(attrVal);
}
}
SimpleFeature feature = featureBuilder.buildFeature( Long.toString(internalId) );
featureList.add(feature);
internalId ++;
}
SimpleFeatureCollection featureCollection = DataUtilities.collection(featureList);
return featureCollection;
}