當前位置: 首頁>>代碼示例>>Java>>正文


Java PrecisionModel.FLOATING屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:Code4SocialGood,項目名稱:C4SG-Obsolete,代碼行數:19,代碼來源:UserMapper.java

示例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;
}
 
開發者ID:reuven,項目名稱:modelingcommons,代碼行數:11,代碼來源:GISExtensionState.java

示例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;
}
 
開發者ID:geoserver,項目名稱:geofence,代碼行數:53,代碼來源:GeometryUtility.java

示例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;
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:10,代碼來源:AllowAllAuthorization.java

示例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;
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:31,代碼來源:DefaultSecurityContext.java

示例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));
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:33,代碼來源:SecurityContextAreaAuthorizationTest.java

示例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));
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:28,代碼來源:SecurityContextAreaAuthorizationTest.java

示例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));
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:28,代碼來源:SecurityContextAreaAuthorizationTest.java

示例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);
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:13,代碼來源:SecurityContextAreaAuthorizationTest.java

示例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;
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:11,代碼來源:OddFeatureAuthorization.java

示例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);
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:13,代碼來源:CustomBeanLayerTest.java

示例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;
}
 
開發者ID:terrestris,項目名稱:momo3-backend,代碼行數:58,代碼來源:GeoServerImporterService.java


注:本文中的com.vividsolutions.jts.geom.PrecisionModel.FLOATING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。