本文整理汇总了Java中com.vividsolutions.jts.operation.buffer.BufferOp.bufferOp方法的典型用法代码示例。如果您正苦于以下问题:Java BufferOp.bufferOp方法的具体用法?Java BufferOp.bufferOp怎么用?Java BufferOp.bufferOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.operation.buffer.BufferOp
的用法示例。
在下文中一共展示了BufferOp.bufferOp方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
@Override
public Geometry call() {
bufferedGeom =PolygonOp.removeInteriorRing(bufferedGeom);
if(!bufferedGeom.isValid()){
bufferedGeom=JTSUtil.repair(bufferedGeom);
//System.out.println(Arrays.toString(bufferedGeom.getCoordinates()));
/*PrecisionModel pm=new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
GeometryFactory gf = new GeometryFactory(pm);
Coordinate[]cc=new Coordinate[bufferedGeom.getCoordinates().length+1];
for(int i=0;i<bufferedGeom.getCoordinates().length;i++){
cc[i]=bufferedGeom.getCoordinates()[i];
}
cc[cc.length-1]=cc[0];
bufferedGeom=gf.createPolygon(cc);*/
}
bufferedGeom =BufferOp.bufferOp(bufferedGeom,bufferingDistance,BufferParameters.CAP_SQUARE,BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
return bufferedGeom;
}
示例2: buffer
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
public IGeometry buffer(IGeometry geom, double distance, int nSegments,
int cap, int join) {
try {
Geometry jtsGeom = JtsGeOxygene.makeJtsGeom(geom);
BufferParameters bufferParam = new BufferParameters(nSegments, cap, join,
BufferParameters.DEFAULT_MITRE_LIMIT);
Geometry jtsBuffer = BufferOp.bufferOp(jtsGeom, distance, bufferParam);
return JtsGeOxygene.makeGeOxygeneGeom(jtsBuffer);
} catch (Exception e) {
JtsAlgorithms.logger.error(I18N.getString("JtsAlgorithms.BufferError")); //$NON-NLS-1$
if (JtsAlgorithms.logger.isDebugEnabled()) {
JtsAlgorithms.logger.debug(I18N
.getString("JtsAlgorithms.BufferDistance") + distance); //$NON-NLS-1$
JtsAlgorithms.logger.debug(I18N
.getString("JtsAlgorithms.BufferSegments") + nSegments); //$NON-NLS-1$
JtsAlgorithms.logger.debug(I18N.getString("JtsAlgorithms.Cap") + cap); //$NON-NLS-1$
JtsAlgorithms.logger
.debug(I18N.getString("JtsAlgorithms.Geometry") + ((geom != null) ? geom.toString() : I18N.getString("JtsAlgorithms.NullGeometry"))); //$NON-NLS-1$ //$NON-NLS-2$
JtsAlgorithms.logger.debug(e.getMessage());
}
e.printStackTrace();
return null;
}
}
示例3: bufferWithParams
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
/**
* Returns a buffered geometry with old shapes in the center of new ones. If
* the buffer is issued at single side then a negative offset renders the
* shape on the left while a positive offset on the right
*/
public static Geometry bufferWithParams(Geometry geometry, Double offset, Boolean singleSided, Integer quadrantSegments, Integer capStyle, Integer joinStyle, Double mitreLimit) {
double d = 0.0D;
if (offset != null) {
d = offset.doubleValue();
}
Boolean ss = false;
if (singleSided != null) {
ss = singleSided;
}
BufferParameters bufferparameters = new BufferParameters();
//Custom code to be able to draw only on the side of the offset curve
bufferparameters.setSingleSided(ss);
if (quadrantSegments != null) {
bufferparameters.setQuadrantSegments(quadrantSegments.intValue());
}
if (capStyle != null) {
bufferparameters.setEndCapStyle(capStyle.intValue());
}
if (joinStyle != null) {
bufferparameters.setJoinStyle(joinStyle.intValue());
}
if (mitreLimit != null) {
bufferparameters.setMitreLimit(mitreLimit.doubleValue());
}
return BufferOp.bufferOp(geometry, d, bufferparameters);
}
示例4: process
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
@Execute
public void process() throws Exception {
checkNull(inMap);
int joinStyle;
if (pJoinstyle.equals(JOIN_MITRE)) {
joinStyle = BufferParameters.JOIN_MITRE;
} else if (pJoinstyle.equals(JOIN_BEVEL)) {
joinStyle = BufferParameters.JOIN_BEVEL;
} else {
joinStyle = BufferParameters.JOIN_ROUND;
}
int endCapStyle;
if (pCapstyle.equals(CAP_FLAT)) {
endCapStyle = BufferParameters.CAP_FLAT;
} else if (pCapstyle.equals(CAP_SQUARE)) {
endCapStyle = BufferParameters.CAP_SQUARE;
} else {
endCapStyle = BufferParameters.CAP_ROUND;
}
FeatureGeometrySubstitutor fgs = new FeatureGeometrySubstitutor(inMap.getSchema(), MultiPolygon.class);
DefaultFeatureCollection outMaptmp = new DefaultFeatureCollection("new", fgs.getNewFeatureType());
GeometryFactory gf = GeometryUtilities.gf();
List<SimpleFeature> featuresList = FeatureUtilities.featureCollectionToList(inMap);
pm.beginTask("Buffering geometries...", featuresList.size());
for( SimpleFeature feature : featuresList ) {
Geometry geometry = (Geometry) feature.getDefaultGeometry();
BufferParameters bP = new BufferParameters(quadrantSegments, endCapStyle, joinStyle, mitreLimit);
Geometry bufferedGeom = BufferOp.bufferOp(geometry, pBuffer, bP);
List<Polygon> polygons = new ArrayList<Polygon>(bufferedGeom.getNumGeometries());
for( int i = 0; i < bufferedGeom.getNumGeometries(); i++ ) {
Geometry geometryN = bufferedGeom.getGeometryN(i);
if (geometryN instanceof Polygon) {
polygons.add((Polygon) geometryN);
} else {
pm.errorMessage("Ignored non polygonal geometry in: " + geometryN.toText());
}
}
MultiPolygon multiPolygon = gf.createMultiPolygon(polygons.toArray(GeometryUtilities.TYPE_POLYGON));
SimpleFeature newFeature = fgs.substituteGeometry(feature, multiPolygon);
outMaptmp.add(newFeature);
pm.worked(1);
}
pm.done();
outMap = outMaptmp;
}
示例5: executeAnalysis
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
public Geometry executeAnalysis(int analysis, Object[] outputRow) throws KettleException{
Geometry result = null;
Object o = data.one[data.referenceIndex];
if(o != null && (!meta.isAlgoDual() || data.two!=null)){
Geometry geom = (Geometry) o;
switch (analysis){
case 0:
result = geom.union(checkGeometry(data.two[data.compareIndex]));
break;
case 1:
result = geom.intersection(checkGeometry(data.two[data.compareIndex]));
break;
case 2:
try{
double dist = Double.parseDouble(meta.getDistField());
BufferParameters bufParams = new BufferParameters();
if(meta.getSide().equals(Messages.getString("SpatialAnalysisMeta.Side.Right")))
bufParams.setSingleSided(true);
if(meta.getSide().equals(Messages.getString("SpatialAnalysisMeta.Side.Left"))){
bufParams.setSingleSided(true);
dist *= -1;
}
bufParams.setEndCapStyle(meta.getCapAsInt());
bufParams.setJoinStyle(meta.getJoinAsInt());
bufParams.setMitreLimit(BufferParameters.DEFAULT_MITRE_LIMIT);
result = BufferOp.bufferOp(geom, dist, bufParams);
}catch(Exception e){
throw new KettleException(Messages.getString("SpatialAnalysis.Exception.WrongParameterType1") + Messages.getString("SpatialAnalysisDialog.DistField.Label") + Messages.getString("SpatialAnalysis.Exception.WrongParameterType2"));
}
break;
case 3:
result = geom.symDifference(checkGeometry(data.two[data.compareIndex]));
break;
case 4:
result = geom.getInteriorPoint();
break;
case 5:
result = geom.getEnvelope();
break;
case 6:
result = geom.getCentroid();
break;
case 7:
result = geom.getBoundary();
break;
case 8:
result = geom.difference(checkGeometry(data.two[data.compareIndex]));
break;
case 9:
result = geom.convexHull();
break;
case 10:
result = geom.reverse();
break;
case 11:
int length = geom.getNumGeometries();
if(length > 1){
for(int i = 0 ; i < geom.getNumGeometries() - 1; i++){
putRow(data.outputRowMeta, RowDataUtil.addValueData(outputRow, data.outputIndex, geom.getGeometryN(i)));
}
}
result = geom.getGeometryN(length - 1);
break;
default:
break;
}
}
return result.isEmpty() ? null : result;
}
示例6: buffer
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
public static Geometry buffer(ValueMetaInterface metaA, Object dataA, Double distance, BufferParameters bufParams) throws KettleValueException{
if (dataA==null || !metaA.isGeometry())
return null;
return BufferOp.bufferOp(metaA.getGeometry(dataA), distance, bufParams);
}
示例7: extractBoundary
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
private Geometry extractBoundary(String name, ArrayList<RelationMember> osmShape) {
LineSequencer seq = new LineSequencer();
for (RelationMember mem : osmShape) {
Entity other = lookup.lookup(mem.getMemberId());
if (other==null) {
continue;
}
if (!(other instanceof Way)) {
logger.warn("Not way type ("+other.getClass().getSimpleName()+") boundary in "+name);
continue;
}
Way way = (Way) other;
LineString ls = extractLineString(name, way.getWayNodes());
if (ls!=null) {
seq.add(ls);
}
}
Geometry geom = null;
try {
geom = seq.getSequencedLineStrings();
} catch (Exception e) {
logger.warn("Geom exception '"+e.getMessage()+"' for: "+name);
}
if (geom!=null) {
CoordinateList list = new CoordinateList(geom.getCoordinates());
list.closeRing();
LinearRing ring = gf.createLinearRing(list.toCoordinateArray());
//cleanup geometry (for sure http://lists.refractions.net/pipermail/jts-devel/2008-May/002466.html)
Geometry res = BufferOp.bufferOp(gf.createPolygon(ring), 0);
if (res.getArea()<=0.0) {
logger.warn("Empty geom for: "+name);
return null;
}
return res;
} else {
logger.warn("No geom for: "+name);
return null;
}
}
示例8: buffer
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
/**
* Computes a buffer area around this geometry having the given width. The
* buffer of a Geometry is the Minkowski sum or difference of the geometry
* with a disc of radius <code>abs(distance)</code>.
* <p>
* Mathematically-exact buffer area boundaries can contain circular arcs.
* To represent these arcs using linear geometry they must be approximated with line segments.
* The buffer geometry is constructed using 8 segments per quadrant to approximate
* the circular arcs.
* The end cap style is <code>CAP_ROUND</code>.
* <p>
* The buffer operation always returns a polygonal result. The negative or
* zero-distance buffer of lines and points is always an empty {@link Polygon}.
* This is also the result for the buffers of degenerate (zero-area) polygons.
*
* @param distance the width of the buffer (may be positive, negative or 0)
* @return a polygonal geometry representing the buffer region (which may be
* empty)
* @throws TopologyException if a robustness error occurs
* @see #buffer(double, int)
* @see #buffer(double, int, int)
*/
public Geometry buffer(double distance) {
return BufferOp.bufferOp(this, distance);
}
示例9: buffer
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
/**
* Computes a buffer area around this geometry having the given width. The
* buffer of a Geometry is the Minkowski sum or difference of the geometry
* with a disc of radius <code>abs(distance)</code>.
* <p/>
* Mathematically-exact buffer area boundaries can contain circular arcs.
* To represent these arcs using linear geometry they must be approximated with line segments.
* The buffer geometry is constructed using 8 segments per quadrant to approximate
* the circular arcs.
* The end cap style is <code>CAP_ROUND</code>.
* <p/>
* The buffer operation always returns a polygonal result. The negative or
* zero-distance buffer of lines and points is always an empty {@link Polygon}.
* This is also the result for the buffers of degenerate (zero-area) polygons.
*
* @param distance the width of the buffer (may be positive, negative or 0)
* @return a polygonal geometry representing the buffer region (which may be
* empty)
* @throws TopologyException if a robustness error occurs
* @see #buffer(double, int)
* @see #buffer(double, int, int)
*/
public Geometry buffer(double distance) {
return BufferOp.bufferOp(this, distance);
}
示例10: buffer
import com.vividsolutions.jts.operation.buffer.BufferOp; //导入方法依赖的package包/类
/**
* Computes a buffer area around this geometry having the given width. The
* buffer of a Geometry is the Minkowski sum or difference of the geometry
* with a disc of radius <code>abs(distance)</code>.
* <p>
* Mathematically-exact buffer area boundaries can contain circular arcs.
* To represent these arcs using linear geometry they must be approximated with line segments.
* The buffer geometry is constructed using 8 segments per quadrant to approximate
* the circular arcs.
* The end cap style is <code>CAP_ROUND</code>.
* <p>
* The buffer operation always returns a polygonal result. The negative or
* zero-distance buffer of lines and points is always an empty {@link Polygon}.
* This is also the result for the buffers of degenerate (zero-area) polygons.
*
* @param distance
* the width of the buffer (may be positive, negative or 0)
* @return a polygonal geometry representing the buffer region (which may be
* empty)
*
* @throws TopologyException
* if a robustness error occurs
*
* @see #buffer(double, int)
* @see #buffer(double, int, int)
*/
public Geometry buffer(double distance) {
return BufferOp.bufferOp(this, distance);
}