当前位置: 首页>>代码示例>>Java>>正文


Java DouglasPeuckerSimplifier.simplify方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier.simplify方法的典型用法代码示例。如果您正苦于以下问题:Java DouglasPeuckerSimplifier.simplify方法的具体用法?Java DouglasPeuckerSimplifier.simplify怎么用?Java DouglasPeuckerSimplifier.simplify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier的用法示例。


在下文中一共展示了DouglasPeuckerSimplifier.simplify方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMergedBuffers

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
public Geometry getMergedBuffers() {
        if (this.mergedBuffers == null) {
//            synchronized (this) {
                Collection<Geometry> polygons = new ArrayList<>();
                for (Stop stop : this.stops.values()) {
                    if (getStopTimesForStop(stop.stop_id).isEmpty()) {
                        continue;
                    }
                    if (stop.stop_lat > -1 && stop.stop_lat < 1 || stop.stop_lon > -1 && stop.stop_lon < 1) {
                        continue;
                    }
                    Point stopPoint = gf.createPoint(new Coordinate(stop.stop_lon, stop.stop_lat));
                    Polygon stopBuffer = (Polygon) stopPoint.buffer(.01);
                    polygons.add(stopBuffer);
                }
                Geometry multiGeometry = gf.buildGeometry(polygons);
                this.mergedBuffers = multiGeometry.union();
                if (polygons.size() > 100) {
                    this.mergedBuffers = DouglasPeuckerSimplifier.simplify(this.mergedBuffers, .001);
                }
//            }
        }
        return this.mergedBuffers;
    }
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:25,代码来源:GTFSFeed.java

示例2: operand

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
/**
 * Simplification of a geometry (Douglas-Peuker algorithm)
 */

@operator (
		value = "simplification",
		category = { IOperatorCategory.SPATIAL, IOperatorCategory.SP_TRANSFORMATIONS },
		concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION, IConcept.SPATIAL_TRANSFORMATION })
@doc (
		value = "A geometry corresponding to the simplification of the operand (geometry, agent, point) considering a tolerance distance.",
		comment = "The algorithm used for the simplification is Douglas-Peucker",
		examples = { @example (
				value = "self simplification 0.1",
				equals = "the geometry resulting from the application of the Douglas-Peuker algorithm on the geometry of the agent applying the operator with a tolerance distance of 0.1.",
				test = false) })
public static IShape simplification(final IScope scope, final IShape g1, final Double distanceTolerance) {
	if (g1 == null || g1.getInnerGeometry() == null) { return g1; }
	if (g1.isPoint()) { return g1.copy(scope); }
	final Geometry geomSimp = DouglasPeuckerSimplifier.simplify(g1.getInnerGeometry(), distanceTolerance);
	if (geomSimp != null && !geomSimp.isEmpty() && geomSimp.isSimple()) { return new GamaShape(g1, geomSimp); }
	return g1.copy(scope);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:Spatial.java

示例3: combineIntoOneGeometry

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
public static Geometry combineIntoOneGeometry(
		final Geometry geometry1,
		final Geometry geometry2 ) {
	if (geometry1 == null) {
		return geometry2;
	}
	else if (geometry2 == null) {
		return geometry1;
	}
	final List<Geometry> geometry = new ArrayList<Geometry>();
	geometry.add(geometry1);
	geometry.add(geometry2);
	return DouglasPeuckerSimplifier.simplify(
			combineIntoOneGeometry(geometry),
			SIMPLIFICATION_MAX_DEGREES);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:17,代码来源:RasterUtils.java

示例4: check

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
private Geometry check(Geometry geometry) {
	if (maxCoordinatesInGeometry > 0) {
		int distanceTolerance = 10;
		while (geometry.getNumPoints() > maxCoordinatesInGeometry) {
			geometry = DouglasPeuckerSimplifier.simplify(geometry, distanceTolerance);
			distanceTolerance *= 2;
		}
	}
	if (roundCoordinates) {
		final double factor = Math.pow(10, roundNumberOfDecimals);
		geometry.apply(new CoordinateFilter() {

			@Override
			public void filter(Coordinate coord) {
				coord.x = Math.round(coord.x * factor) / factor;
				coord.y = Math.round(coord.y * factor) / factor;
			}
		});
	}
	return geometry;
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:22,代码来源:DefaultCriterionFilterConverter.java

示例5: filtreDouglasPeucker

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
/**
 * tente d'appliquer filtre de douglas peucker a une geometrie. en cas
 * d'echec, renvoie la geometrie initiale
 * @param geom
 * @param seuil
 * @return the resulting Geometry after the application of the DouglasPeucker
 *         filter
 */
public static Geometry filtreDouglasPeucker(Geometry geom, double seuil) {
  if (seuil == 0.0) {
    return (Geometry) geom.clone();
  }
  if (seuil < 0.0) {
    JtsAlgorithms.logger
        .warn(I18N
            .getString("JtsAlgorithms.DouglasPeuckerWithNegativeThreshold") + seuil); //$NON-NLS-1$
    return geom;
  }

  Geometry g = DouglasPeuckerSimplifier.simplify(geom, seuil);

  if ((g == null) || g.isEmpty() || !g.isValid()) {
    JtsAlgorithms.logger.warn(I18N
        .getString("JtsAlgorithms.DouglasPeuckerError")); //$NON-NLS-1$
    JtsAlgorithms.logger.warn(I18N
        .getString("JtsAlgorithms.DouglasPeuckerThreshold") + seuil); //$NON-NLS-1$
    JtsAlgorithms.logger
        .warn(I18N.getString("JtsAlgorithms.Geometry") + geom); //$NON-NLS-1$
    JtsAlgorithms.logger.warn(I18N.getString("JtsAlgorithms.Result") + g); //$NON-NLS-1$
    return geom;
  } else if (g.getGeometryType() != geom.getGeometryType()) {
    JtsAlgorithms.logger.warn(I18N
        .getString("JtsAlgorithms.DouglasPeuckerWithDifferentTypesError")); //$NON-NLS-1$
    JtsAlgorithms.logger.warn(I18N
        .getString("JtsAlgorithms.DouglasPeuckerThreshold") + seuil); //$NON-NLS-1$
    JtsAlgorithms.logger
        .warn(I18N.getString("JtsAlgorithms.Geometry") + geom); //$NON-NLS-1$
    JtsAlgorithms.logger.warn(I18N.getString("JtsAlgorithms.Result") + g); //$NON-NLS-1$
    return geom;
  } else {
    return g;
  }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:44,代码来源:JtsAlgorithms.java

示例6: prepareROI

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
/**
 * Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.
 * 
 * @param roi a {@link Geometry} in model space.
 * @param mt2d an {@link AffineTransform} that maps from raster to model space. This is already referred to the pixel corner.
 * @return a {@link ROI} suitable for using with JAI.
 * @throws ProcessException in case there are problems with ivnerting the provided {@link AffineTransform}. Very unlikely to happen.
 */
public static ROI prepareROI( Geometry roi, AffineTransform mt2d ) throws Exception {
    // transform the geometry to raster space so that we can use it as a ROI source
    Geometry rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse()));

    // simplify the geometry so that it's as precise as the coverage, excess coordinates
    // just make it slower to determine the point in polygon relationship
    Geometry simplifiedGeometry = DouglasPeuckerSimplifier.simplify(rasterSpaceGeometry, 1);

    // build a shape using a fast point in polygon wrapper
    return new ROIShape(new FastLiteShape(simplifiedGeometry));
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:20,代码来源:CoverageUtilities.java

示例7: getFootprint

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
public static Geometry getFootprint(
		final ReferencedEnvelope projectedReferenceEnvelope,
		final GridCoverage gridCoverage ) {
	try {
		final Envelope sampleEnvelope = gridCoverage.getEnvelope();
		final double avgSpan = (projectedReferenceEnvelope.getSpan(0) + projectedReferenceEnvelope.getSpan(1)) / 2;
		final MathTransform gridCrsToWorldCrs = CRS.findMathTransform(
				gridCoverage.getCoordinateReferenceSystem(),
				GeoWaveGTRasterFormat.DEFAULT_CRS,
				true);
		final Coordinate[] polyCoords = getWorldCoordinates(
				sampleEnvelope.getMinimum(0),
				sampleEnvelope.getMinimum(1),
				sampleEnvelope.getMaximum(0),
				sampleEnvelope.getMaximum(1),
				gridCrsToWorldCrs.isIdentity() ? 2 : (int) Math.min(
						Math.max(
								(avgSpan * MIN_SEGMENTS) / SIMPLIFICATION_MAX_DEGREES,
								MIN_SEGMENTS),
						MAX_SEGMENTS),
				gridCrsToWorldCrs);
		final Polygon poly = new GeometryFactory().createPolygon(polyCoords);
		if (polyCoords.length > MAX_VERTICES_BEFORE_SIMPLIFICATION) {
			final Geometry retVal = DouglasPeuckerSimplifier.simplify(
					poly,
					SIMPLIFICATION_MAX_DEGREES);
			if (retVal.isEmpty()) {
				return poly;
			}
			return retVal;
		}
		else {
			return poly;
		}
	}
	catch (MismatchedDimensionException | TransformException | FactoryException e1) {
		LOGGER.warn(
				"Unable to calculate grid coverage footprint",
				e1);
	}
	return null;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:43,代码来源:RasterUtils.java

示例8: toDto

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public Feature toDto(SimpleFeature feature, int maxCoordsPerFeature) throws IllegalArgumentException {
	if (feature == null) {
		throw new IllegalArgumentException("No feature was passed.");
	}
	Feature dto = new Feature(feature.getID());
	HashMap<String, Attribute> attributeMap = new HashMap<String, Attribute>();
	GeometryDescriptor geometryDescr = feature.getFeatureType().getGeometryDescriptor();
	for (org.opengis.feature.type.AttributeDescriptor desc : feature.getType().getAttributeDescriptors()) {
		if (null == geometryDescr || !geometryDescr.getName().getLocalPart().equals(desc.getLocalName())) {
			Object obj = feature.getAttribute(desc.getName());
			Attribute<?> value = toPrimitive(obj, desc.getType());
			attributeMap.put(desc.getLocalName(), value);
		}
	}

	dto.setAttributes(attributeMap);
	dto.setId(feature.getID());
	dto.setUpdatable(false);
	dto.setDeletable(false);
	dto.setLabel(feature.getID());

	Object defaultGeometry = feature.getDefaultGeometry();
	if (defaultGeometry instanceof Geometry) {
		Geometry geometry = (Geometry) defaultGeometry;
		if (maxCoordsPerFeature > 0) {
			// we take the tolerance from the 1st geometry to make sure we don't end up with an empty geometry !
			Envelope firstEnvelope = geometry.getGeometryN(0).getEnvelopeInternal();
			double distanceTolerance = (firstEnvelope.getWidth() + firstEnvelope.getHeight()) / maxCoordsPerFeature;
			while (geometry.getNumPoints() > maxCoordsPerFeature) {
				geometry = DouglasPeuckerSimplifier.simplify(geometry, distanceTolerance);
				distanceTolerance *= 2;
			}
		}
		try {
			dto.setGeometry(GeometryConverterService.fromJts(geometry));
		} catch (JtsConversionException e) {
			// OK then, no geometry for you...
			log.error("Error while parsing geometry from GML: " + e.getMessage());
		}
	}
	return dto;
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:44,代码来源:FeatureConverter.java

示例9: simplifyDP

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
public static Geometry simplifyDP(Geometry g, double tolerance)
{
  return DouglasPeuckerSimplifier.simplify(g, tolerance);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:5,代码来源:GeomFunction.java

示例10: simplifyLineString

import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier; //导入方法依赖的package包/类
/**
 * The purpose of this method is to use the
 * Douglas-Peuker line simplification algorithm to reduce the
 * number of points in the polyline while maintaining route fidelity.
 *
 * @param polyline - The full set of points from the device.
 * @return Simplified Geometry.
 */
public Geometry simplifyLineString(final Coordinate[] polyline) {

    final LineString lineString = geometryFactory.createLineString(polyline);
    return DouglasPeuckerSimplifier.simplify(lineString, 0.00001);
}
 
开发者ID:smitchell,项目名称:garmin-fit-geojson,代码行数:14,代码来源:GarminFitService.java


注:本文中的com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier.simplify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。