ToolMap
Loading...
Searching...
No Matches
tmGISDataVectorSHP Class Reference
Inheritance diagram for tmGISDataVectorSHP:
tmGISDataVector tmGISData tmGISDataVectorSHPMemory

Public Member Functions

virtual bool Open (const wxString &filename, bool bReadWrite=FALSE)
 Generic open code.
 
virtual bool Close ()
 
virtual tmRealRect GetMinimalBoundingRectangle ()
 
virtual TM_GIS_SPATIAL_TYPES GetSpatialType ()
 
virtual bool SetSpatialFilter (tmRealRect filter, int type)
 
virtual bool SetAttributeFilter (const wxString &query)
 
virtual wxRealPoint * GetNextDataLine (int &nbvertex, long &oid, bool &isOver)
 
virtual wxRealPoint * GetNextDataPoint (long &oid, bool &isOver)
 
virtual int GetNextDataPolygonInfo (long &oid)
 
virtual wxRealPoint * GetNextDataPolygon (int currentring, int &nbvertex)
 
virtual OGRPolygon * GetNextDataOGRPolygon (long &oid)
 Get the actual feature as polygon.
 
virtual OGRFeature * GetNextFeature ()
 
virtual bool ResetReading ()
 
virtual OGRFeature * GetFeatureByOID (long oid)
 
bool SelectFeatureByOID (long oid)
 
virtual OGRGeometry * GetNextGeometry (bool restart, long &oid)
 
OGRLayer * GetLayerRef ()
 
virtual wxString GetMetaDataAsHtml ()
 Get Metadata information well formated.
 
virtual wxString GetDataSizeAsHtml (int iPrecision=2)
 Getting Data size.
 
virtual int GetCount ()
 Counting features in layer.
 
virtual int GetFieldsCount ()
 Get the number of fields.
 
virtual bool GetFieldsName (wxArrayString &Fields, long oid=wxNOT_FOUND)
 Getting fields name.
 
virtual bool GetFieldsValue (wxArrayString &values, long oid)
 
bool GetDistinctFieldsValue (const wxString &fieldname, wxArrayString &values)
 
virtual wxArrayLong * SearchData (const tmRealRect &rect, int type)
 Search spatial data.
 
virtual wxArrayLong * GetAllData ()
 Get OID of all features back from the shapefile.
 
virtual bool GetSnapCoord (const wxRealPoint &clickpt, double buffersize, wxArrayRealPoints &snapppts, int snaptype)
 Get snapping coordinate.
 
virtual bool CreateFile (const wxFileName &filename, int type)
 Create the shp on the disk.
 
virtual bool AddFieldText (const wxString &fieldname, int size)
 Add text fields to the Shp.
 
virtual bool AddFieldNumeric (const wxString &fieldname, bool isfloat=false)
 Add int field to the Shp.
 
virtual bool AddFieldDate (const wxString &fieldname)
 Add date field to the Shp.
 
virtual long AddGeometry (OGRGeometry *Geom, const long &oid, int layertype=wxNOT_FOUND)
 Add a geometry in the shapefile.
 
virtual bool SetNextFeature (bool resetreading=false)
 Move to next feature.
 
virtual bool SetFieldValue (const wxString &value, int fieldtype, int iindex)
 Add value into a field.
 
virtual long GetActualOID ()
 Return the actual OID.
 
virtual void SetActualOID (long oid)
 Set the OID for the current Feature.
 
virtual bool UpdateFeature ()
 Update the actual feature.
 
virtual void CloseGeometry ()
 
virtual bool GetFieldNumeric (const wxString &fieldname, int &fieldvalue)
 
virtual bool SetFieldNumeric (const wxString &fieldname, int fieldvalue)
 
bool ExecuteSQLQuery (const wxString &query)
 
long GetFeatureIDIntersectedBy (OGRGeometry *geometry)
 
long GetFeatureIDIntersectedOnRaster (OGRPoint *geometry)
 
bool Rasterize (double rasterizefactor)
 
void RemoveRasterizeFile ()
 
virtual bool DeleteFile (const wxString &layername)
 
virtual bool CreateSpatialIndex (GDALProgressFunc progress, void *pfProgressData)
 
virtual bool CopyToFile (const wxFileName &filename, const wxString &drivername, bool overwrite)
 
- Public Member Functions inherited from tmGISDataVector
OGRLineString * InsertVertex (OGRGeometry *pointbuffer, wxRealPoint ptclicked, OGRLineString *line, int &inseredvertex)
 Insert a vertex in a passed line.
 
OGRLineString * InsertVertexMultiple (OGRLineString *line, OGRMultiPoint *vertex, const wxArrayInt &point_pos)
 Insert multiple vertex into line.
 
virtual bool UpdateGeometry (OGRGeometry *geom, const long &oid)
 
virtual bool SplitGeometry (OGRGeometryCollection *gCol, const long &oid, wxArrayLong &AddedIds, int layertype)
 Save splitted geometry to file.
 
virtual OGRGeometryCollection * GetGeometryColByOID (wxArrayLong *OIDs)
 
wxString GetFieldsMetadata ()
 Formating fields info into html string.
 
bool CutLineAtVertex (long oid, const wxRealPoint &clickedpt, int searchRadius, int layertype)
 Cut line in two at specified point.
 
bool CutLineGeometry (OGRLineString *line1, OGRLineString *line2, OGRMultiLineString &res1, OGRMultiLineString &res2)
 Cut two lines where they intesects.
 
bool CutLineMultiple (OGRLineString *linetocut, OGRMultiLineString *cutlines, OGRMultiLineString &results)
 Cut one line with multiple line.
 
bool LinesMerge (OGRMultiLineString *linetomerge, OGRGeometry **linemerged)
 Merge lines.
 
virtual wxArrayLong * SearchIntersectingGeometry (OGRGeometry *intersectinggeom)
 
virtual int IsRaster ()
 
- Public Member Functions inherited from tmGISData
 tmGISData ()
 Constructor.
 
 ~tmGISData ()
 Destructor.
 
int GetDataType ()
 
void SetCoordConvert (tmCoordConvert *coordconvert)
 
tmCoordConvertGetCoordConvert ()
 
wxString GetShortFileName ()
 
wxString GetFullFileName ()
 
virtual bool IsPointSnapped (const wxRealPoint &point, int snaptype, long excludeoid=wxNOT_FOUND)
 

Protected Attributes

GDALDataset * m_Datasource
 
OGRLayer * m_Layer
 
GDALDataset * m_RasterizeDataset
 
OGRFeature * m_Feature
 
int m_polyTotalRings
 
int m_MultiFeaturesIterator
 
int m_MultiFeaturesOid
 
- Protected Attributes inherited from tmGISData
int m_ClassType
 

Additional Inherited Members

- Static Public Member Functions inherited from tmGISDataVector
static void InitGISDriversVector ()
 
static wxString GetAllVectorGISFormatsWildcards ()
 
static tmGISDataVectorCreateGISVectorBasedOnType (const int &gis_format_index)
 
static tmGISDataVectorCreateGISVectorBasedOnExt (const wxString &extension)
 
static OGRGeometry * CreateOGRGeometry (const tmRealRect &rect)
 Create a OGR geometry.
 
- Static Public Member Functions inherited from tmGISData
static void InitGISDrivers (bool bRaster=TRUE, bool bVector=TRUE)
 Init the GDAL / OGR driver.
 
static wxString GetAllSupportedGISFormatsWildcards ()
 Return all supported formats.
 
static wxArrayString GetAllSupportedGISFormatsExtensions ()
 Returning all extensions in an array string.
 
static tmGISDataCreateGISBasedOnType (const int &gis_format_index)
 Create an object of the specified format.
 
static tmGISDataCreateGISBasedOnExt (const wxString &extension)
 
static tmGISDataLoadLayer (tmLayerProperties *layerprop)
 Call this function for loading a layer.
 
static void EnableLogging (bool enable=true)
 
static bool IsLoggingEnabled ()
 
- Protected Member Functions inherited from tmGISDataVector
virtual wxString GetTableName (TOC_GENERIC_NAME type)
 
bool CheckGEOSIntersection (GEOSGeom *rect, GEOSGeom *object)
 Compute real GEOS intersection (not bounding box)
 
bool CheckGEOSCrosses (GEOSGeom *g1, GEOSGeom *g2)
 Check for crossing (not bounding box)
 
GEOSGeom CreateGEOSGeometry (OGRGeometry *geom)
 Create a GEOS geometry.
 
GEOSGeom CreateGEOSGeometry (const tmRealRect &rect)
 Create a GEOS geometry.
 
bool GetVertexIntersection (OGRGeometry *geometry, OGRGeometry *buffer, wxArrayRealPoints &points)
 Search if a vertex intersect the passed geometry.
 
bool GetBeginEndInterseciton (OGRGeometry *geometry, OGRGeometry *buffer, wxArrayRealPoints &points)
 Search if a Begin/End vertex intersect the passed geometry.
 
- Protected Member Functions inherited from tmGISData
wxString GetMinimalBoundingRectangleAsHtml (int iprecision=2)
 Get Minimal bounding rectangle as html.
 
- Static Protected Member Functions inherited from tmGISDataVector
static OGRGeometry * SafeCreateFromGEOS (GEOSGeom geom)
 Safe conversion function.
 
static OGRGeometry * SafeBuffer (OGRGeometry *ogrgeom, int size)
 
static OGRGeometry * SafeIntersection (OGRGeometry *geom1, OGRGeometry *geom2)
 Compute intersection.
 
static OGRGeometry * SafeUnion (OGRGeometry *union1, OGRGeometry *line)
 Compute Union.
 
static OGRGeometry * CreateOGRGeometry (const wxRealPoint &pt)
 

Member Function Documentation

◆ AddFieldDate()

bool tmGISDataVectorSHP::AddFieldDate ( const wxString &  fieldname)
virtual

Add date field to the Shp.

Parameters
fieldnamename of the field
Author
Lucien Schreiber (c) CREALP 2008
Date
15 November 2008

◆ AddFieldNumeric()

bool tmGISDataVectorSHP::AddFieldNumeric ( const wxString &  fieldname,
bool  isfloat = false 
)
virtual

Add int field to the Shp.

Parameters
fieldnamename of the field
isfloatSet this value to true if you want a float field
Returns
true if field added, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
15 November 2008

◆ AddFieldText()

bool tmGISDataVectorSHP::AddFieldText ( const wxString &  fieldname,
int  size 
)
virtual

Add text fields to the Shp.

Parameters
fieldnamename of the field
sizelength of the field
Returns
true if field added, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
15 November 2008

◆ AddGeometry()

long tmGISDataVectorSHP::AddGeometry ( OGRGeometry *  Geom,
const long &  oid,
int  layertype = wxNOT_FOUND 
)
virtual

Add a geometry in the shapefile.

Parameters
Geoma OGRGeometry
oidthe oid of the new geometry added
layertypeNot used for shapefiles
Returns
true if geometry added, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
16 November 2008

Reimplemented from tmGISDataVector.

◆ Close()

bool tmGISDataVectorSHP::Close ( )
virtual

Reimplemented from tmGISData.

◆ CloseGeometry()

void tmGISDataVectorSHP::CloseGeometry ( )
virtual

Reimplemented from tmGISDataVector.

◆ CreateFile()

bool tmGISDataVectorSHP::CreateFile ( const wxFileName &  filename,
int  type 
)
virtual

Create the shp on the disk.

Parameters
filenamethe filename we want to create
typeone of the following values :
  • 0 for lines
  • 1 for points
  • 2 for polygons
Returns
true if file creation succeed, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
15 November 2008

Reimplemented in tmGISDataVectorSHPMemory.

◆ CreateSpatialIndex()

bool tmGISDataVectorSHP::CreateSpatialIndex ( GDALProgressFunc  progress,
void *  pfProgressData 
)
virtual

Reimplemented from tmGISData.

◆ DeleteFile()

bool tmGISDataVectorSHP::DeleteFile ( const wxString &  layername)
virtual

Reimplemented from tmGISDataVector.

◆ GetActualOID()

long tmGISDataVectorSHP::GetActualOID ( )
virtual

Return the actual OID.

Returns
the actual OID or wxNOT_FOUND if not found
Author
Lucien Schreiber (c) CREALP 2009
Date
26 March 2009

◆ GetAllData()

wxArrayLong * tmGISDataVectorSHP::GetAllData ( )
virtual

Get OID of all features back from the shapefile.

Author
Lucien Schreiber (c) CREALP 2009
Date
31 March 2009

Reimplemented from tmGISData.

◆ GetCount()

int tmGISDataVectorSHP::GetCount ( )
virtual

Counting features in layer.

This function return the number of lines, points, or polygons stored in the layer.

Todo:
Implement this function in tmGISDataVectorMYSQL
Returns
Number of features found or -1 if an error is encountered
Author
Lucien Schreiber (c) CREALP 2008
Date
17 September 2008

Reimplemented from tmGISDataVector.

◆ GetDataSizeAsHtml()

wxString tmGISDataVectorSHP::GetDataSizeAsHtml ( int  iPrecision = 2)
virtual

Getting Data size.

Return the size of the dataset

Returns
Human readable and html compliant string containing data size
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

Reimplemented from tmGISData.

◆ GetFeatureByOID()

OGRFeature * tmGISDataVectorSHP::GetFeatureByOID ( long  oid)
virtual

Reimplemented from tmGISDataVector.

◆ GetFieldsCount()

int tmGISDataVectorSHP::GetFieldsCount ( )
virtual

Get the number of fields.

Returns
Number of fields. If -1 is returned, an error occur
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

Reimplemented from tmGISDataVector.

◆ GetFieldsName()

bool tmGISDataVectorSHP::GetFieldsName ( wxArrayString &  Fields,
long  oid = wxNOT_FOUND 
)
virtual

Getting fields name.

Parameters
Fieldsadress of an array string to be filled with fields name
Returns
true if fields name returned succesfully, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

Reimplemented from tmGISDataVector.

◆ GetFieldsValue()

bool tmGISDataVectorSHP::GetFieldsValue ( wxArrayString &  values,
long  oid 
)
virtual

Reimplemented from tmGISDataVector.

◆ GetMetaDataAsHtml()

wxString tmGISDataVectorSHP::GetMetaDataAsHtml ( )
virtual

Get Metadata information well formated.

Returns
An html string to be displayed in the properties dialog
Author
Lucien Schreiber (c) CREALP 2008
Date
22 October 2008

Reimplemented from tmGISData.

◆ GetMinimalBoundingRectangle()

tmRealRect tmGISDataVectorSHP::GetMinimalBoundingRectangle ( )
virtual

Reimplemented from tmGISData.

◆ GetNextDataLine()

wxRealPoint * tmGISDataVectorSHP::GetNextDataLine ( int &  nbvertex,
long &  oid,
bool &  isOver 
)
virtual

Reimplemented from tmGISDataVector.

◆ GetNextDataOGRPolygon()

OGRPolygon * tmGISDataVectorSHP::GetNextDataOGRPolygon ( long &  oid)
virtual

Get the actual feature as polygon.

Parameters
oidthe oid of the returned polygon
Returns
a valid OGRPolygon (must be destroyed by caller) or nullptr
Author
Lucien Schreiber (c) CREALP 2008
Date
17 November 2008

◆ GetNextDataPoint()

wxRealPoint * tmGISDataVectorSHP::GetNextDataPoint ( long &  oid,
bool &  isOver 
)
virtual

Reimplemented from tmGISDataVector.

◆ GetNextDataPolygon()

wxRealPoint * tmGISDataVectorSHP::GetNextDataPolygon ( int  currentring,
int &  nbvertex 
)
virtual

Reimplemented from tmGISDataVector.

◆ GetNextDataPolygonInfo()

int tmGISDataVectorSHP::GetNextDataPolygonInfo ( long &  oid)
virtual

Reimplemented from tmGISDataVector.

◆ GetNextFeature()

OGRFeature * tmGISDataVectorSHP::GetNextFeature ( )
virtual

Reimplemented from tmGISDataVector.

◆ GetNextGeometry()

OGRGeometry * tmGISDataVectorSHP::GetNextGeometry ( bool  restart,
long &  oid 
)
virtual

Reimplemented from tmGISDataVector.

◆ GetSnapCoord()

bool tmGISDataVectorSHP::GetSnapCoord ( const wxRealPoint &  clickpt,
double  buffersize,
wxArrayRealPoints &  snapppts,
int  snaptype 
)
virtual

Get snapping coordinate.

Return, if found, the closest existing coordinate for snapping

Parameters
clickptThe real coordinate of the clicked point
iBufferthe size of the buffer in map unit
snapptthe returned snapping coordinate if function return true
snaptypethe type of snapping : tmSNAPPING_BEGIN_END or tmSNAPPING_VERTEX
Returns
true if a snapping coordinate was found, false otherwise
Author
Lucien Schreiber (c) CREALP 2009
Date
29 January 2009

Reimplemented from tmGISData.

◆ GetSpatialType()

TM_GIS_SPATIAL_TYPES tmGISDataVectorSHP::GetSpatialType ( )
virtual

Reimplemented from tmGISDataVector.

◆ Open()

bool tmGISDataVectorSHP::Open ( const wxString &  filename,
bool  bReadWrite = FALSE 
)
virtual

Generic open code.

Mainly init member values used by all GIS class

Parameters
filenamepath and name of the GIS data to open
bReadWriteShould we open the dataset for r/w operations ?
Returns
Allways TRUE
Author
Lucien Schreiber (c) CREALP 2008
Date
14 July 2008

Reimplemented from tmGISData.

◆ ResetReading()

bool tmGISDataVectorSHP::ResetReading ( )
virtual

Reimplemented from tmGISDataVector.

◆ SearchData()

wxArrayLong * tmGISDataVectorSHP::SearchData ( const tmRealRect rect,
int  type 
)
virtual

Search spatial data.

Parameters
rectReal rectangle for searching data
typeLayertype see tmLayerProperties
Returns
An array containing OID of data found or nullptr if nothing found
Author
Lucien Schreiber (c) CREALP 2008
Date
31 October 2008

Reimplemented from tmGISData.

◆ SetActualOID()

void tmGISDataVectorSHP::SetActualOID ( long  oid)
virtual

Set the OID for the current Feature.

See also SetNextFeature() for more informations about changing actual feature

Parameters
oidOID to set. (converted into int for shapefiles)
Author
Lucien Schreiber (c) CREALP 2009
Date
27 March 2009

◆ SetAttributeFilter()

bool tmGISDataVectorSHP::SetAttributeFilter ( const wxString &  query)
virtual

Reimplemented from tmGISDataVector.

◆ SetFieldValue()

bool tmGISDataVectorSHP::SetFieldValue ( const wxString &  value,
int  fieldtype,
int  iindex 
)
virtual

Add value into a field.

Parameters
valuea wxString containing the value (will be converted in the function)
fieldtypethe type of the field based on : PRJDEF_FIELD_TYPE
iindex0 based field index
Returns
true if value was added to the field
Author
Lucien Schreiber (c) CREALP 2008
Date
17 November 2008

◆ SetNextFeature()

bool tmGISDataVectorSHP::SetNextFeature ( bool  resetreading = false)
virtual

Move to next feature.

Parameters
resetreadingshould we restart iterating features ?
Returns
true if next feature is a valid feature, false otherwise (end of file encountred).
Author
Lucien Schreiber (c) CREALP 2008
Date
17 November 2008

◆ SetSpatialFilter()

bool tmGISDataVectorSHP::SetSpatialFilter ( tmRealRect  filter,
int  type 
)
virtual

Reimplemented from tmGISDataVector.

◆ UpdateFeature()

bool tmGISDataVectorSHP::UpdateFeature ( )
virtual

Update the actual feature.

This function should be used after applying modification to the feature for saving the modification in the file. For exemple after setting fields value with tmGISDataVectorSHP::SetFieldValue() use this function for apply changes

Returns
true if saving features works
Author
Lucien Schreiber (c) CREALP 2008
Date
17 November 2008

The documentation for this class was generated from the following files: