C# Class Mapsui.Providers.Shapefile.ShapeFile

Shapefile dataprovider

The ShapeFile provider is used for accessing ESRI ShapeFiles. The ShapeFile should at least contain the [filename].shp, [filename].idx, and if feature-data is to be used, also [filename].dbf file.

The first time the ShapeFile is accessed, Mapsui will automatically create a spatial index of the shp-file, and save it as [filename].shp.sidx. If you change or update the contents of the .shp file, delete the .sidx file to force Mapsui to rebuilt it. In web applications, the index will automatically be cached to memory for faster access, so to reload the index, you will need to restart the web application as well.

M and Z values in a shapefile is ignored by Mapsui.

Inheritance: IProvider, IDisposable
Afficher le fichier Open project: pauldendulk/Mapsui Class Usage Examples

Méthodes publiques

Méthode Description
Dispose ( ) : void

Disposes the object

GetExtents ( ) : BoundingBox

Returns the extents of the datasource

GetFeature ( uint rowId, IFeatures feature = null ) : IFeature

Gets a datarow from the datasource at the specified index belonging to the specified datatable

GetFeatureCount ( ) : int

Returns the total number of features in the datasource (without any filter applied)

GetFeaturesInView ( BoundingBox box, double resolution ) : IEnumerable
GetGeometriesInView ( BoundingBox bbox ) : Collection

Returns geometries whose bounding box intersects 'bbox'

Please note that this method doesn't guarantee that the geometries returned actually intersect 'bbox', but only that their boundingbox intersects 'bbox'.

This method is much faster than the QueryFeatures method, because intersection tests are performed on objects simplifed by their boundingbox, and using the Spatial Index.

GetGeometry ( uint oid ) : IGeometry

Returns the geometry corresponding to the Object ID

GetObjectIDsInView ( BoundingBox bbox ) : Collection

Returns geometry Object IDs whose bounding box intersects 'bbox'

RebuildSpatialIndex ( ) : void

Forces a rebuild of the spatial index. If the instance of the ShapeFile provider uses a file-based index the file is rewritten to disk.

ShapeFile ( string filename, bool fileBasedIndex = false ) : System

Initializes a ShapeFile DataProvider.

If FileBasedIndex is true, the spatial index will be read from a local copy. If it doesn't exist, it will be generated and saved to [filename] + '.sidx'.

Using a file-based index is especially recommended for ASP.NET applications which will speed up start-up time when the cache has been emptied.

Private Methods

Méthode Description
Close ( ) : void

Closes the datasource

CreateSpatialIndex ( ) : QuadTree

Generates a spatial index for a specified shape file.

CreateSpatialIndexFromFile ( string filename ) : QuadTree

Loads a spatial index from a file. If it doesn't exist, one is created and saved

Dispose ( bool disposing ) : void
GetAllFeatureBoundingBoxes ( ) : IEnumerable

Reads all boundingboxes of features in the shapefile. This is used for spatial indexing.

GetFeaturePrivate ( uint rowId, IFeatures dt ) : IFeature
GetShapeIndex ( uint n ) : int

Gets the file position of the n'th shape

InitializeShape ( string filename, bool fileBasedIndex ) : void
LoadSpatialIndex ( bool loadFromFile ) : void
LoadSpatialIndex ( bool forceRebuild, bool loadFromFile ) : void
Open ( ) : void

Opens the datasource

ParseHeader ( ) : void

Reads and parses the header of the .shx index file

ParseProjection ( ) : void

Reads and parses the projection if a projection file exists

ReadGeometry ( uint oid ) : Geometry

Reads and parses the geometry with ID 'oid' from the ShapeFile

Filtering is not applied to this method

ReadIndex ( ) : int[]

Reads the record offsets from the .shx index file and returns the information in an array

SwapByteOrder ( int i ) : int

Swaps the byte order of an int32

Method Details

Dispose() public méthode

Disposes the object
public Dispose ( ) : void
Résultat void

GetExtents() public méthode

Returns the extents of the datasource
public GetExtents ( ) : BoundingBox
Résultat BoundingBox

GetFeature() public méthode

Gets a datarow from the datasource at the specified index belonging to the specified datatable
public GetFeature ( uint rowId, IFeatures feature = null ) : IFeature
rowId uint
feature IFeatures Datatable to feature should belong to.
Résultat IFeature

GetFeatureCount() public méthode

Returns the total number of features in the datasource (without any filter applied)
public GetFeatureCount ( ) : int
Résultat int

GetFeaturesInView() public méthode

public GetFeaturesInView ( BoundingBox box, double resolution ) : IEnumerable
box BoundingBox
resolution double
Résultat IEnumerable

GetGeometriesInView() public méthode

Returns geometries whose bounding box intersects 'bbox'

Please note that this method doesn't guarantee that the geometries returned actually intersect 'bbox', but only that their boundingbox intersects 'bbox'.

This method is much faster than the QueryFeatures method, because intersection tests are performed on objects simplifed by their boundingbox, and using the Spatial Index.

public GetGeometriesInView ( BoundingBox bbox ) : Collection
bbox BoundingBox
Résultat Collection

GetGeometry() public méthode

Returns the geometry corresponding to the Object ID
public GetGeometry ( uint oid ) : IGeometry
oid uint Object ID
Résultat IGeometry

GetObjectIDsInView() public méthode

Returns geometry Object IDs whose bounding box intersects 'bbox'
public GetObjectIDsInView ( BoundingBox bbox ) : Collection
bbox BoundingBox
Résultat Collection

RebuildSpatialIndex() public méthode

Forces a rebuild of the spatial index. If the instance of the ShapeFile provider uses a file-based index the file is rewritten to disk.
public RebuildSpatialIndex ( ) : void
Résultat void

ShapeFile() public méthode

Initializes a ShapeFile DataProvider.

If FileBasedIndex is true, the spatial index will be read from a local copy. If it doesn't exist, it will be generated and saved to [filename] + '.sidx'.

Using a file-based index is especially recommended for ASP.NET applications which will speed up start-up time when the cache has been emptied.

public ShapeFile ( string filename, bool fileBasedIndex = false ) : System
filename string Path to shape file
fileBasedIndex bool Use file-based spatial index
Résultat System