Shapefile optimizations

Functions

bool Shapefile.BeginPointInShapefile ()
 Caches the coordinates of shapefile points for faster point in shape test. More...
 
void Shapefile.EndPointInShapefile ()
 Clears the cached data allocated by Shapefile.BeginPointInShapefile. More...
 
int Shapefile.get_numPoints (int shapeIndex)
 Returns the number of points in the specified shape of the shapefile. More...
 
bool Shapefile.PointInShape (int shapeIndex, double x, double y)
 Returns boolean value which indicates whether the given point is located within the specified shape. More...
 
int Shapefile.PointInShapefile (double x, double y)
 Returns a number which indicates the index of shapes within which a test point is situated. More...
 
Extents Shapefile.QuickExtents (int shapeIndex)
 Returns the extents of the shape with the given index. More...
 
Point Shapefile.QuickPoint (int shapeIndex, int pointIndex)
 Returns the specified point of shape. More...
 
System.Array Shapefile.QuickPoints (int shapeIndex, ref int numPoints)
 Returns an array with the coordinates of points of the specified shape. More...
 
bool Shapefile.RefreshExtents ()
 Refreshes extents of all shapes in the shapefile. More...
 
bool Shapefile.RefreshShapeExtents (int shapeId)
 Refreshes the extents of the particular shape in the shapefile. More...
 

Properties

bool Shapefile.CacheExtents [get, set]
 Gets or sets a boolean value which indicates whether extents of shape will be recalculated before each redraw. More...
 
bool Shapefile.FastMode [get, set]
 Gets or sets the value which indicates whether fast mode will be used for the shapefile. More...
 
int Shapefile.MinDrawingSize [get, set]
 Gets or sets the value which affects the drawing of small shapes on the screen. More...
 

Detailed Description

Here is a list of properties and methods which doesn't provide additional functionality but can improve the speed of certain operations with shapefile. This module is a part of the documentation of Shapefile class.

dot_inline_dotgraph_30.png

Graph description

Function Documentation

◆ BeginPointInShapefile()

bool Shapefile.BeginPointInShapefile ( )

Caches the coordinates of shapefile points for faster point in shape test.

Shapefile.EndPointInShapefile call is needed to release the memory.

Returns
True on successful caching and false otherwise.

◆ EndPointInShapefile()

void Shapefile.EndPointInShapefile ( )

Clears the cached data allocated by Shapefile.BeginPointInShapefile.

◆ get_numPoints()

int Shapefile.get_numPoints ( int  shapeIndex)

Returns the number of points in the specified shape of the shapefile.

This property is more efficient than calling Shapefile.get_Shape().NumPoints.

Parameters
shapeIndexThe index of the shape.
Returns
The number of points or -1 in case of invalid index.

There is a confusion with name casing for this property. It's actually spelled 'get_NumPoints' in the source code. However because of the known bug in PIA generation process the property ended up spelled 'get_numPoints' in earlier version of PIAs. After some hesitation we decided to keep it that way. See description of the bug here: http://stackoverflow.com/questions/3179676/c-exposed-property-for-com-in-idl-is-showing-as-lower-case-all-of-a-sudden

◆ PointInShape()

bool Shapefile.PointInShape ( int  shapeIndex,
double  x,
double  y 
)

Returns boolean value which indicates whether the given point is located within the specified shape.

The operation is applicable for polygon shapefiles only.

Parameters
shapeIndexThe index shape (polygon) to perform the test.
xX coordinate of the point.
yY coordinate of the point.
Returns
True in case the point is located within polygon and false otherwise.

◆ PointInShapefile()

int Shapefile.PointInShapefile ( double  x,
double  y 
)

Returns a number which indicates the index of shapes within which a test point is situated.

Call Shapefile.BeginPointInShapefile to improve performance.

Parameters
xThe x coordinate of the point.
yThe y coordinate of the point.
Returns
The index of shape.

◆ QuickExtents()

Extents Shapefile.QuickExtents ( int  shapeIndex)

Returns the extents of the shape with the given index.

This operation is faster than Shapefile.get_Shape().Extents as there is no need to read all the shape data.

Parameters
shapeIndexThe index of the shape.
Returns
The extents of shape or NULL reference on failure.

◆ QuickPoint()

Point Shapefile.QuickPoint ( int  shapeIndex,
int  pointIndex 
)

Returns the specified point of shape.

This operation doesn't require the reading of all shape date from disk, therefore it will be faster when editing mode is false.

Parameters
shapeIndexThe index of shape.
pointIndexThe point index.
Returns
The point or the NULL reference on the invalid index.

◆ QuickPoints()

System.Array Shapefile.QuickPoints ( int  shapeIndex,
ref int  numPoints 
)

Returns an array with the coordinates of points of the specified shape.

The value specified in numPoints will be adjusted if the specified number is greater than the number of points.

Parameters
shapeIndexThe index of shape.
numPointsThe number of point to return.
Returns
The array of double type with coordinates of the point. Every two elements represent x and y coordinate of the point respectively.

◆ RefreshExtents()

bool Shapefile.RefreshExtents ( )

Refreshes extents of all shapes in the shapefile.

See Shapefile.CacheExtents for the details.

Returns
The value can be omitted.
New API 4.8:
Added in version 4.8

◆ RefreshShapeExtents()

bool Shapefile.RefreshShapeExtents ( int  shapeId)

Refreshes the extents of the particular shape in the shapefile.

See Shapefile.CacheExtents for the details.

Parameters
shapeIdThe index of the shape which extents are to be refreshed.
Returns
True on success and false in case of invalid shape index.
New API 4.8:
Added in version 4.8

Properties

◆ CacheExtents

bool Shapefile.CacheExtents
getset

Gets or sets a boolean value which indicates whether extents of shape will be recalculated before each redraw.

When the property is set to:

  • false: MapWinGIS recalculates the extents of each shape before the redraw assuming that some changes MIGHT took place. The operation can slow down the drawing for large shapefiles.

  • true: MapWinGIS doesn't recalculate extents of the shapes which leads to faster drawing but also makes a developer responsible for updating the extents of shapes in the due time. To do it one need to call Shapefile.RefreshShapeExtents after each editing operation. Otherwise there is a chance that old extents of the shape may lie outside the visible area of the map and the shape won't be displayed.

When Shapefile.FastMode is turned on the extents are cached automatically in spite of this property. Also the extents will be automatically refreshed after Shape.put_XY call. However Shape.get_Point().x = [value] call will not be tracked. Therefore Shapefile.RefreshShapeExtents will still be needed.
To avoid confusion use the following recommendation:

  1. If you work with small shapefile and performance isn't a problem, set this property to false.

  2. If the performance is an issue:
    • if you write a new code, set this property to true (as well as Shapefile.FastMode), but assign new coordinates to the points by calling Shape.put_XY only;
    • if you are bound to the exiting code with Shape.get_Point.x = [value] calls, set this property to true but call Shapefile.RefreshShapeExtents after the editing operations.
New API 4.8:
Added in version 4.8

◆ FastMode

bool Shapefile.FastMode
getset

Gets or sets the value which indicates whether fast mode will be used for the shapefile.

The mode ensures faster drawing but makes the client responsible for the refreshing of shapefile extents after editing operation (see Shapefile.RefreshExtents and Shapefile.RefreshShapeExtents). It's highly recommended to use the mode for large shapefiles.

New API 4.8:
Added in version 4.8

◆ MinDrawingSize

int Shapefile.MinDrawingSize
getset

Gets or sets the value which affects the drawing of small shapes on the screen.

The objects with scaled size less than this value will be drawn as a single dot. This can noticeably increase performance for large shapefiles at full scale. But with the increase of speed the quality of drawing will be deteriorating. The default value is 1.

New API 4.8:
Added in version 4.8