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


Java PrecisionModel.FLOATING_SINGLE屬性代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.PrecisionModel.FLOATING_SINGLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java PrecisionModel.FLOATING_SINGLE屬性的具體用法?Java PrecisionModel.FLOATING_SINGLE怎麽用?Java PrecisionModel.FLOATING_SINGLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.vividsolutions.jts.geom.PrecisionModel的用法示例。


在下文中一共展示了PrecisionModel.FLOATING_SINGLE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CellLocationReference

/**
 * Creates a new reference
 * @param envelope  the bounding envelope, which allows points
 *                  to be associated with their containing {@link com.foursquare.geo.shapes.indexing.CellLocation}s
 * @param levelSizes a list representing the maximum depth of the index (length of array)
 *                   and the 2D branching factor at each level (the value at each index)
 *                   a quadtree-like index, with a maximum depth of 5 could be realized
 *                   as <code>new int[]{2, 2, 2, 2, 2}</code>
 */
public CellLocationReference(ReferencedEnvelope envelope, int[] levelSizes) {
  this.envelope = envelope;
  this.levelSizes = levelSizes.clone();
  this.hashCodeValue = envelope.hashCode() + Arrays.hashCode(this.levelSizes);
  geometryFactory = new GeometryFactory(
    new PrecisionModel(PrecisionModel.FLOATING_SINGLE)
  );
  logger.debug("GeometryFactory using PrecisionModel {}", geometryFactory.getPrecisionModel());
}
 
開發者ID:foursquare,項目名稱:shapefile-geo,代碼行數:18,代碼來源:CellLocationReference.java

示例2: circle

@operator (
		value = { "inter", "intersection" },
		category = { IOperatorCategory.SPATIAL })
@doc (
		value = "A geometry resulting from the intersection between the two geometries",
		special_cases = { "returns nil if one of the operands is nil" },
		examples = { @example (
				value = "square(10) inter circle(5)",
				equals = "circle(5)") },
		see = { "union", "+", "-" })
public static IShape inter(final IScope scope, final IShape g1, final IShape g2) {
	if (g2 == null || g1 == null) { return null; }
	if (g2.isPoint() && g1.covers(g2.getLocation())) { return g2.copy(scope); }
	if (g1.isPoint() && g2.covers(g1.getLocation())) { return g1.copy(scope); }
	Geometry geom = null;
	final Geometry geom1 = g1.getInnerGeometry();
	final Geometry geom2 = g2.getInnerGeometry();
	try {

		geom = geom1.intersection(geom2);
	} catch (final Exception ex) {
		try {
			final PrecisionModel pm = new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
			geom = GeometryPrecisionReducer.reducePointwise(geom1, pm)
					.intersection(GeometryPrecisionReducer.reducePointwise(geom2, pm));
		} catch (final Exception e) {
			// AD 12/04/13 : Addition of a third method in case of
			// exception
			try {
				geom = geom1.buffer(0.01, BufferParameters.DEFAULT_QUADRANT_SEGMENTS, BufferParameters.CAP_FLAT)

						.intersection(geom2.buffer(0.01, BufferParameters.DEFAULT_QUADRANT_SEGMENTS,
								BufferParameters.CAP_FLAT));
			} catch (final Exception e2) {
				return null;
			}
		}
	}
	if (geom == null || geom.isEmpty()) { return null; }
	// WARNING The attributes of the left-hand shape are kept, but not
	// those of the right-hand shape
	final GamaShape result = new GamaShape(g1, geom);
	result.losePredefinedProperty();
	return result;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:45,代碼來源:Spatial.java

示例3: union

@operator (
		value = { "+", "union" },
		category = { IOperatorCategory.SPATIAL },
		concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION })
@doc (
		usages = @usage (
				value = "if the right-operand is a point, a geometry or an agent, returns the geometry resulting from the union between both geometries",
				examples = @example (
						value = "geom1 + geom2",
						equals = "a geometry corresponding to union between geom1 and geom2",
						isExecutable = false)))
public static IShape union(final IScope scope, final IShape g1, final IShape g2) {
	if (g1 == null) {
		if (g2 == null) { return null; }
		return g2.copy(scope);
	}
	if (g2 == null) { return g1.copy(scope); }
	final Geometry geom1 = g1.getInnerGeometry();
	final Geometry geom2 = g2.getInnerGeometry();
	Geometry geom;
	try {
		geom = geom1.union(geom2);
	} catch (final Exception e) {
		try {
			final PrecisionModel pm = new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
			geom = GeometryPrecisionReducer.reducePointwise(geom1, pm)
					.intersection(GeometryPrecisionReducer.reducePointwise(geom2, pm));
		} catch (final Exception e1) {
			try {
				geom = Spatial.Transformations.translated_by(scope, g2.copy(scope), new GamaPoint(0.01, 0))
						.getInnerGeometry().union(geom1);

			} catch (final Exception e2) {
				// AD 12/04/13 : Addition of a third method in case of
				// exception
				try {
					geom = geom1.buffer(0.01, 0, BufferParameters.CAP_SQUARE)
							.union(geom2.buffer(0.01, 0, BufferParameters.CAP_SQUARE));
				} catch (final Exception e3) {
					geom = Spatial.Transformations.rotated_by(scope, g2.copy(scope), 0.1).getInnerGeometry()
							.union(geom1);
				}
			}
		}

	}
	if (geom == null || geom.isEmpty()) { return null; }
	final GamaShape result = new GamaShape(g1, geom);
	result.losePredefinedProperty();
	return result;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:51,代碼來源:Spatial.java

示例4: calculateUnion

private ODLGeom calculateUnion(Iterable<ODLGeom> inputGeoms, String ESPGCode) {
	try {
		Spatial.initSpatial();
		GridTransforms transforms = new GridTransforms(ESPGCode);

		PrecisionModel pm = new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
		GeometryPrecisionReducer reducer = new GeometryPrecisionReducer(pm);

		// process shapes into grid with reduced precision
		ArrayList<Geometry> gridGeoms = new ArrayList<>();
		for (ODLGeom geom : inputGeoms) {
			if (geom != null) {
				ODLGeomImpl gimpl = (ODLGeomImpl) geom;
				if (gimpl.getJTSGeometry() != null) {
					com.vividsolutions.jts.geom.Geometry g = gimpl.getJTSGeometry();

					// convert to grid
					g = JTS.transform(g, transforms.getWGS84ToGrid().getMathTransform());

					// reduce precision as it stops holes appearing with our UK postcode data
					g = reducer.reduce(g);

					gridGeoms.add(g);

				}

			}
		}

		if (gridGeoms.size() == 0) {
			return null;
		}

		// combine
		Geometry combinedGrid = combineIntoOneGeometry(gridGeoms);

		// transform back
		Geometry combinedWGS84 = JTS.transform(combinedGrid, transforms.getGridToWGS84().getMathTransform());

		return new ODLLoadedGeometry(combinedWGS84);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}

}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:45,代碼來源:GeomUnion.java

示例5: precisionModel

@Provides
@Singleton
public PrecisionModel precisionModel() {
    return new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
}
 
開發者ID:enviroCar,項目名稱:enviroCar-server,代碼行數:5,代碼來源:CoreModule.java


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