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


Java BufferParameters.setSingleSided方法代码示例

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


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

示例1: bufferWithParams

import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入方法依赖的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

示例2: executeAnalysis

import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入方法依赖的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

示例3: addCleanOffsetCurves

import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入方法依赖的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


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