com.supermap.analyst

Class BufferAnalyst

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


  • public class BufferAnalyst
    extends java.lang.Object
    The BufferAnalyst class

    Buffer analyst is the fundamental spatial analyst in GIS. Buffer zone is the construction of area features by extending outward from point, line, or polygon features over a specified distance. Buffer analyst can be used in many fields, such as a power wire has a five meters dangerous zone around it, you can create a buffer on map for this wire to indicate this dangerous zone.

    Buffer analyst supports point dataset, line dataset, region dataset (recordset) and network dataset. The buffer analyst of the network dataset focuses on edges.

    For region objects, it is best to check the topology to exclude the in-plane intersection before buffer analysis. The so-called in-plane intersection refers to the region that intersects itself. As shown in the diagram, the node number represents the node order of a region object.

    Negative Radius

    • If the buffer radius is numeric, only region data supports this type;
    • If the buffer radius is field or field expression with negative value, the point, line data is its absolute value; for region data, if buffers are united, we use absolute value; if not, we use negative radius.

    For parameters of buffer, see the BufferAnalystParameter class.

    • Method Detail

      • createBuffer

        public static boolean createBuffer(DatasetVector sourceDataset,
                                           DatasetVector resultDataset,
                                           BufferAnalystParameter bufferAnalystParameter,
                                           boolean isUnion,
                                           boolean isAttributeRetained)
        Creates the buffer for the vector dataset.Only internal use.
        Parameters:
        sourceDataset - The specified vector dataset that creates buffer area.
        resultDataset - The vector dataset to store the result of the buffer analysis. It must be the region dataset.
        bufferAnalystParameter - The specified BufferAnalystParameter object.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result. For region objects, it is required that the objects in the source data do not intersect with each other.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        Returns:
        A boolean. true if it creates the vector dataset buffer successfully; Otherwise, false.
        Example:
        The following code shows how to create buffer area according to the given line dataset
        public void bufferAnalystForDataset() {
        
                // Returns the vector dataset which will be used to build buffer.
                Workspace workspace = new Workspace();
                String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
                DatasourceConnectionInfo datasourceConnectionInfo = newDatasourceConnectionInfo(rootPath + "/shanghai/shanghai.udb", "shanghai", "");
                Datasource targetDatasource = workspace.getDatasources().open(datasourceConnectionInfo);
                DatasetVector datasetRoad = (DatasetVector) targetDatasource.getDatasets().get("Road_L");
        
                // Creates a region vector dataset to store the result after peforming the buffer analysis
                String resultDatasetName = targetDatasource.getDatasets().getAvailableDatasetName("resultDatasetBuffer");
                DatasetVectorInfo datasetvectorInfo = new DatasetVectorInfo();
                datasetvectorInfo.setType(DatasetType.REGION);
                datasetvectorInfo.setName(resultDatasetName);
                datasetvectorInfo.setEncodeType(EncodeType.NONE);
                DatasetVector resultDatasetBuffer = targetDatasource.getDatasets().create(datasetvectorInfo);
        
                // Sets BufferAnalystParameter
                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();
                bufferAnalystParam.setEndType(BufferEndType.FLAT);
                bufferAnalystParam.setLeftDistance(20);
                bufferAnalystParam.setRightDistance(20);
        
                // Calls createBuffer()
                BufferAnalyst.createBuffer(datasetRoad,
                                           resultDatasetBuffer, bufferAnalystParam, false, true);
        
                // Releases resources
                workspace.dispose();
            }
      • createBuffer

        public static boolean createBuffer(Recordset sourceRecordset,
                                           DatasetVector resultDataset,
                                           BufferAnalystParameter bufferAnalystParameter,
                                           boolean isUnion,
                                           boolean isAttributeRetained)
        Creates the buffer according to the given vector recordset.
        Parameters:
        sourceRecordset - The specified vector recordset that creates buffer area.
        resultDataset - The vector dataset to store the result of the buffer analysis. It must be the region dataset.
        bufferAnalystParameter - The specified BufferAnalystParameter object.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result. For region objects, it is required that the objects in the source data do not intersect with each other.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        Returns:
        A boolean. true if it creates the vector recordset buffer successfully; Otherwise, false.
        Example:
        The following code shows how to create buffer area according to the given line recordset
         public void bufferAnalystForRecordset(Recordset recordsetLine, DatasetVector resultDatasetBuffer)
                {
                // Sets the parameterof buffer analysis
                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();
                bufferAnalystParam.setEndType(BufferEndType.FLAT);
                bufferAnalystParam.setLeftDistance(20);
                bufferAnalystParam.setRightDistance(20);
        
                // Calls createBuffer() to build buffer for recordset
                BufferAnalyst.createBuffer(recordsetLine, resultDatasetBuffer, bufferAnalystParam, false,true);
        
             }
             
      • createMultiBuffer

        public static boolean createMultiBuffer(DatasetVector sourceDataset,
                                                DatasetVector resultDataset,
                                                double[] bufferRadiuses,
                                                BufferRadiusUnit bufferRadiusUnit,
                                                int semicircleSegments,
                                                boolean isUnion,
                                                boolean isAttributeRetained,
                                                boolean isRing)
        Creates the multi-buffers according to the given vector dataset.
        Parameters:
        sourceDataset - The specified vector dataset that creates multi-buffers area.
        resultDataset - The specified dataset for storing the buffer analysis result.
        bufferRadiuses - The specified multi buffer radius list.
        bufferRadiusUnit - The specified buffer radius unit.
        semicircleSegments - The specified the number of edge to fit.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        isRing - Whether to generate a ring buffer.
        Returns:
        A boolean. true if it creates the vector dataset multiple buffer successfully; Otherwise, false.
        Example:
        See the sample of createMultiBuffer(Recordset, DatasetVector, double[], BufferRadiusUnit, int, boolean, boolean, boolean) method.
      • createMultiBuffer

        public static boolean createMultiBuffer(Recordset sourceRecordset,
                                                DatasetVector resultDataset,
                                                double[] bufferRadiuses,
                                                BufferRadiusUnit bufferRadiusUnit,
                                                int semicircleSegments,
                                                boolean isUnion,
                                                boolean isAttributeRetained,
                                                boolean isRing)
        Creates the multi-buffers for a vector recordset.
        Parameters:
        sourceRecordset - The specified vector recordset that creates multi-buffer area.
        resultDataset - The specified dataset for storing the buffer analysis result.
        bufferRadiuses - The specified multi buffer radius list.
        bufferRadiusUnit - The specified buffer radius unit.
        semicircleSegments - The specified the number of edge to fit.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        isRing - Whether to generate a ring buffer.
        Returns:
        A boolean. true if it creates the vector recordset multiple buffer successfully; Otherwise, false.
        Example:
        The following code shows how to create multiple buffer area according to the given line recordset.
         public void multiBufferForRecordset(Recordset sourceRecordset,
                        DatasetVector resultDataset) {
                // Use array to save the radius of multiple buffer area
                double[] arrayRadius = { 30, 90, 100, 200 };
         
                //Set the arc fitting number is 20
                int semicircleSegments = 20;
         
                BufferAnalyst.createMultiBuffer(sourceRecordset, resultDataset, arrayRadius, BufferRadiusUnit.Meter, semicircleSegments, false,true, false);
         }
         
      • createLineOneSideMultiBuffer

        public static boolean createLineOneSideMultiBuffer(DatasetVector sourceDataset,
                                                           DatasetVector resultDataset,
                                                           double[] bufferRadiuses,
                                                           BufferRadiusUnit bufferRadiusUnit,
                                                           int semicircleSegments,
                                                           boolean isLeft,
                                                           boolean isUnion,
                                                           boolean isAttributeRetained,
                                                           boolean isRing)
        Creates the one-side multi buffer for a vector line dataset.
        Parameters:
        sourceDataset - The specified vector dataset that creates multi-buffers area.
        resultDataset - The specified vector dataset to store the result of the buffer analysis. It must be the region dataset.
        bufferRadiuses - The specified multi buffer radius list.
        bufferRadiusUnit - The specified buffer radius unit.
        semicircleSegments - The specified the number of edge to fit.
        isLeft - Whether to generate a left buffer.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        isRing - Whether to generate a ring buffer.
        Returns:
        A boolean. true if it creates the vector line dataset one side buffer successfully; Otherwise, false.
        Example:
        The following code shows how to create multiple buffer area according to the given line dataset.
         public void oneSideMultiBufferForDataset(DatasetVector sourceDataset,
                        DatasetVector resultDataset) {
                // Use array to save the radius of multiple buffer area
                double[] arrayRadius ={30,100};
         
                //Set the arc fitting number is 20
                int semicircleSegments = 20;
         
                //Set the type of single side buffer to the left buffer
                boolean isLeft = true;
         
                BufferAnalyst.createLineOneSideMultiBuffer(sourceDataset, resultDataset, arrayRadius, BufferRadiusUnit.Meter, semicircleSegments, isLeft, false, true, false);
         }
         
      • createLineOneSideMultiBuffer

        public static boolean createLineOneSideMultiBuffer(Recordset sourceRecordset,
                                                           DatasetVector resultDataset,
                                                           double[] bufferRadiuses,
                                                           BufferRadiusUnit bufferRadiusUnit,
                                                           int semicircleSegments,
                                                           boolean isLeft,
                                                           boolean isUnion,
                                                           boolean isAttributeRetained,
                                                           boolean isRing)
        Creates the one-side multi buffer for a vector recordset.
        Parameters:
        sourceRecordset - The specified vector recordset that creates multi-buffer area.
        resultDataset - The specified vector dataset to store the result of the buffer analysis. It must be the region dataset.
        bufferRadiuses - The specified multi buffer radius list.
        bufferRadiusUnit - The specified buffer radius unit.
        semicircleSegments - The specified the number of edge to fit.
        isLeft - Whether to generate a left buffer.
        isUnion - Whether to merge all buffers, i.e., whether to perform a union operation on the buffers of the objects in the source data and return the result.
        isAttributeRetained - whether to reserve the fields of the objects in the source dataset. However, For the region dataset, if union the objects and the buffer zone, this parameter is invalid, namely the isUnion is set to true.
        isRing - Whether to generate a ring buffer.
        Returns:
        A boolean. Return true if successful; otherwise, false.
        Example:
        See the sample of createLineOneSideMultiBuffer(DatasetVector, DatasetVector, double[], BufferRadiusUnit, int, boolean, boolean, boolean, boolean) method.