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


Java BufferOp类代码示例

本文整理汇总了Java中com.vividsolutions.jts.operation.buffer.BufferOp的典型用法代码示例。如果您正苦于以下问题:Java BufferOp类的具体用法?Java BufferOp怎么用?Java BufferOp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BufferOp类属于com.vividsolutions.jts.operation.buffer包,在下文中一共展示了BufferOp类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:21,代码来源:MaskVectorLayer.java

示例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;
  }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:25,代码来源:JtsAlgorithms.java

示例3: jtsInset

import com.vividsolutions.jts.operation.buffer.BufferOp; //导入依赖的package包/类
public static ArrayList<ArrayList<Point2D>> jtsInset(double d, ArrayList<Loop> ls){
	MultiPolygon mp = ToMultiPoly(ls);
	BufferOp bf = new BufferOp(mp);
	bf.setQuadrantSegments(5);
	Geometry g = bf.getResultGeometry(d);
	@SuppressWarnings("unchecked")
	List<Polygon> polies = (List<Polygon>)PolygonExtracter.getPolygons(g);
	ArrayList<ArrayList<Point2D>> output = new  ArrayList<ArrayList<Point2D>>();
	for(Polygon p : polies){
		int num = p.getNumInteriorRing();
		output.add(conv(p.getExteriorRing()));
		for(int i=0;i<num;i++)output.add(conv(p.getInteriorRingN(i)));
	}
	if(output.size()==0) return null;
	for(ArrayList<Point2D> ps : output){
		if(ps.size()==0) continue;
		for(int i=0;i<ps.size()-1;i++){
			try{ while(Utils2D.equiv(ps.get(i), ps.get(i+1))) ps.remove(i);
			} catch(IndexOutOfBoundsException e){
				break;
			}
		}
	}
	return output;
}
 
开发者ID:nick-parker,项目名称:Bread,代码行数:26,代码来源:NativeInset.java

示例4: 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);
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:36,代码来源:FluxoFilterFunction.java

示例5: buffer

import com.vividsolutions.jts.operation.buffer.BufferOp; //导入依赖的package包/类
public Shape buffer(Shape shape, Double distance, Map<String, Object> params) {
  Geometry geometry = toGeometry(shape);
  BufferParameters parameters = new BufferParameters();
  if (params != null) {
    bindParameters(parameters, params);
  }

  BufferOp ops = new BufferOp(geometry, parameters);
  return toShape(ops.getResultGeometry(distance));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:11,代码来源:OShapeBuilder.java

示例6: 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;

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:54,代码来源:OmsBuffer.java

示例7: 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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:70,代码来源:SpatialAnalysis.java

示例8: 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);    
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:6,代码来源:ValueDataUtil.java

示例9: 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;
	}
}
 
开发者ID:jkubos,项目名称:osm-address-extractor,代码行数:53,代码来源:GeoExtractor.java

示例10: addCleanOffsetCurves

import com.vividsolutions.jts.operation.buffer.BufferOp; //导入依赖的package包/类
private void addCleanOffsetCurves(Collection offsetCurves, Geometry sourceCurve, BufferParameters parameters, Double offsetDistance, Integer qS) {
    parameters.setSingleSided(true);
    parameters.setQuadrantSegments(qS);
    Geometry sidedBuffer = new BufferOp(sourceCurve, parameters)
            .getResultGeometry(offsetDistance)
            .getBoundary();
    Collection offsetSegments = new ArrayList();
    // Segments located entirely under this distance are excluded
    double lowerBound = Math.abs(offsetDistance) * Math.sin(Math.PI / (4 * qS));
    // Segments located entirely over this distance are included
    // note that the theoretical approximation made with quadrantSegments
    // is offset*cos(PI/(4*quadrantSegments) but offset*cos(PI/(2*quadrantSegments)
    // is used to make sure to include segments located on the boundary
    double upperBound = Math.abs(offsetDistance) * Math.cos(Math.PI / (2 * qS));
    for (int i = 0; i < sidedBuffer.getNumGeometries(); i++) {
        Coordinate[] cc = sidedBuffer.getGeometryN(i).getCoordinates();
        PointPairDistance ppd = new PointPairDistance();
        DistanceToPoint.computeDistance(sourceCurve, cc[0], ppd);
        double dj = ppd.getDistance();
        for (int j = 1; j < cc.length; j++) {
            double di = dj;
            ppd = new PointPairDistance();
            DistanceToPoint.computeDistance(sourceCurve, cc[j], ppd);
            dj = ppd.getDistance();
            // segment along or touching the source geometry : eclude it
            if (Math.max(di, dj) < lowerBound || di == 0 || dj == 0) {
                continue;
            } // segment along the buffer boundary : include it
            else if (Math.min(di, dj) > upperBound) {
                LineString segment = sourceCurve.getFactory().createLineString(
                        new Coordinate[]{cc[j - 1], cc[j]});
                offsetSegments.add(segment);
            } // segment entirely located inside the buffer : exclude it
            else if (Math.min(di, dj) > lowerBound && Math.max(di, dj) < upperBound) {
                continue;
            } // segment with a end at the offset distance and the other
            // located within the buffer : divide it
            else {
                // One of the coordinates is closed to but not on the source
                // curve and the other is more or less closed to offset distance
                divide(offsetSegments, sourceCurve, cc[j - 1], cc[j], di, dj, lowerBound, upperBound);
            }
        }
    }
    offsetCurves.addAll(merge(offsetSegments));
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:47,代码来源:FluxoFilterFunction.java

示例11: indexAddresses

import com.vividsolutions.jts.operation.buffer.BufferOp; //导入依赖的package包/类
private void indexAddresses() {
	
	double delta = appoximateMetersToDegrees(5.0);
	
	geoExtractor.getAddresses().stream().filter(address -> address.position!=null).forEach(address -> {
		
		Envelope geom = BufferOp.bufferOp(address.position, delta).getEnvelopeInternal();
	
		addressesIndex.insert(geom, address);
	});
}
 
开发者ID:jkubos,项目名称:osm-address-extractor,代码行数:12,代码来源:AddressTreeLinker.java

示例12: 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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:26,代码来源:Geometry.java

示例13: 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);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:26,代码来源:Geometry.java

示例14: 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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:30,代码来源:Geometry.java


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