com.supermap.analyst

Class BufferAnalystGeometry

  • java.lang.Object
    • com.supermap.analyst.BufferAnalystGeometry


  • public class BufferAnalystGeometry
    extends java.lang.Object
    The BufferAnalystGeometry class.
    • Method Detail

      • createBuffer

        public static GeoRegion createBuffer(Geometry geometry,
                                             BufferAnalystParameter bufferAnalystParameter,
                                             PrjCoordSys prjCoordSys)
        Create buffer for the given geometry object with the BufferAnalystParameter object. You can specify the source coordinate system.

        When the unit of the geometry source projected coordinate system can't convert to thesetRadiusUnitof the bufferAnalystParameter, you can use this method to specify the source projected coordinate system.

        For example, geometry object A is in a dataset with geographic coordinate system, it uses the longitude and latitude, the unit is degree. The RadiusUnit is meter, and the radius is 50. If you do not specify the source coordinate system, the result will be a buffer region object with 50 degrees as the radius, which is not the result wanted. When the source projected coordinate system is specified, the system will perform the projection transformation with the source projected coordinate system to let the geometry A has the same unit with the analysis radius (or can be converted to the unit of the analysis radius), create the buffer, and then convert it to the source projected coordinate system.

        Note: While performing buffer analysis on points or regions, thesetEndType()method of theBufferAnalystParameterobject can only be set toBufferEndType.ROUND.Round.

        Parameters:
        geometry - The specified Geometry object.
        bufferAnalystParameter - The specified buffer analysis parameter object, the parameter left \ right buffer can not be set to 0, that is not supported to generate unilateral buffer. For information on buffer analysis parameters, see BufferAnalystParameter Class
        prjCoordSys - The specified source projected coordinate system.
        Returns:
        Create a buffer based on a geometry object ,return a region object buffer is successfully created. Returns a empty region object if failed.
        Example:
        The following example demonstrates how to create the buffer area according to the given geometry object.
         public void bufferAnalystForGeometry() {
                // Returns the vector dataset where the object (used to build buffer) is located
                Workspace workspace = new Workspace();
                String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
                DatasourceConnectionInfo datasourceConnectionInfo = new DatasourceConnectionInfo(rootPath + "/shanghai.udb", "shanghai", "");
                Datasource targetDatasource = workspace.getDatasources().open(datasourceConnectionInfo);
                DatasetVector datasetRoad = (DatasetVector) targetDatasource.getDatasets().get("Road_L");
        
                // Returns the record of line geometric object through querying
                QueryParameter queryParam = new QueryParameter();
                queryParam.setAttributeFilter("ClassID=411001");
                queryParam.setHasGeometry(true);
                Recordset queryRecordset = datasetRoad.query(queryParam);
        
                // New a dataset to store buffers of geometric objects
                String resultDatasetName = targetDatasource.getDatasets().getAvailableDatasetName("resultDataset");
                DatasetVectorInfo datasetvectorInfo = new DatasetVectorInfo();
                datasetvectorInfo.setType(DatasetType.REGION);
                datasetvectorInfo.setName(resultDatasetName);
                datasetvectorInfo.setEncodeType(EncodeType.NONE);
                DatasetVector resultDataset = targetDatasource.getDatasets().create(datasetvectorInfo);
                Recordset resultDatasetRecordset = resultDataset.getRecordset(false, CursorType.DYNAMIC);
        
                // Sets the parameter of buffer analysis
                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();
                bufferAnalystParam.setEndType(BufferEndType.FLAT);
                bufferAnalystParam.setLeftDistance(20);
                bufferAnalystParam.setRightDistance(20);
        
                // Builds a buffer for line geometric object and stores the result into the result dataset
                PrjCoordSys prj = queryRecordset.getDataset().getPrjCoordSys();
                while (!queryRecordset.isEOF()) {
                    GeoLine geolineForBuffer = (GeoLine) queryRecordset.getGeometry();
                    GeoRegion geometryBuffer = BufferAnalystGeometry.createBuffer(geolineForBuffer, bufferAnalystParam, prj);
                    resultDatasetRecordset.addNew(geometryBuffer);
                    resultDatasetRecordset.update();
                    queryRecordset.moveNext();
                }
        
                // Releases resources
                queryRecordset.dispose();
                resultDatasetRecordset.dispose();
                workspace.dispose();
                }