Drawings SDK Developer Guide > Working with .dwg Files > Working with GEO Functionality
Working with GEO Functionality

There are several classes that provide the following functions for working with geography data (geo-data):

  • Setting a coordinate system (creating a geo-data entity).
  • Updating a coordinate system.
  • Creating a geo-map entity.
  • Saving a geo-map into a drawing database.
  • Changing the geo-map type and resolution, etc.

The following picture demonstrates a diagram with Geo-related classes.

This class diagram consists of core Geo-related classes and the classes of four Geo-related modules.

The main Geo-related class is OdDbGeoData. This class defines an active coordinate system (CS) and other global database Geo-related properties. It provides functions for adding a geolocation marker (one per drawing) and a background map to a drawing.

Note: A geolocation marker is drawn on each viewport if the GEOMARKERVISIBILITY system variable is set to 1.

To get the OdDbGeoData object ID, use the global oddbGetGeoDataObjId() method.

The OdDbGeoPositionMarker class represents a marker at a position with comments (not the same as a geolocation marker which is one per drawing; geoposition markers can be multiple per drawing). Geoposition markers can be moved around a geo-map.

OdDbGeoCoordinateSystem is an abstract class that represents a coordinate reference system (CRS) definition.

OdDbGeoCoordinateSystemCategory is an abstract class used for representing a category which holds string identifiers referring to a group of coordinate reference systems.

OdDbGeoCoordinateSystemTransformer is an abstract class that represents a transformer object which is used to transform points from the source CRS to the target CRS.

Protocol extensions

For working with abstract classes, there is a set of protocol extension classes:

  • OdDbGeoDataPE is an abstract class for geo-data needs. Sample implementation is in the OdGeoData module.
  • OdDbGeoCoordinateSystemCategoryPE is an abstract class that contains interfaces of virtual methods used for creating coordinate system categories. Sample implementation is in the OdGeoData module in the OdDbGeoCoordinateSystemCategoryPEImpl class.
  • OdDbGeoCoordinateSystemPE is an abstract class that contains interfaces of virtual methods used for creating objects that are an OdDbGeoCoordinateSystem class's inheritors. Sample implementation is in the OdGeoData module in the OdDbGeoCoordinateSystemPeImpl class.
  • OdDbGeoCoordinateSystemTransformerPE is an abstract class that represents a protocol extension for a transformer object used to transform points from the source coordinate reference system to the target coordinate reference system. Sample implementation is in the OdGeoData module.
  • OdDbGeoMapPE is a class for geo-map needs. Sample implementation is in the OdDbGeoMapPE module.

Modules for working with geo-data

There are four modules that demonstrate how to work with geo-data.

OdGeoData module implements OdDbGeoCoordinateSystemCategoryPE, OdDbGeoCoordinateSystemPE, OdDbGeoCoordinateSystemTransformerPE, and OdDbGeoDataPE classes and is located in Drawing\Extensions\OdGeoData. This module uses csmap and tinyxml libraries.

Note: OdGeoData module does not support coordinate type kCoordTypLocal.

GeolocationObj module provides the following functions for working with geo-maps:

  • Creating geo-map objects and adding them to a database.
  • Rendering a drawing that contains geo-map objects.
  • Changing geo-map object properties.

GeolocationObj module is located in Drawing\Examples\GeolocationObj and consists of several classes:

  • OdDbGeoMap — A piece of the global map (as an image).
  • OdDbGeoMapDef — OdDbGeoMap object definition.
  • OdDbGeoMapPE — Protocol extensions for working with geo-map objects.
  • OdDbGeoMapFieldsPE — Set/get methods for OdDbGeoMap object properties. This class is used in classes that inherit the OdDbGeoMapPE class.

GeolocationObj module implements all OdDbGeoMap methods except the updateMapImage() method because it depends on whether the OdDbGeoMapPE module is loaded.

OdDbGeoMapPE module implements the OdDbGeoMapPE class functionality. It is located in Drawing\Examples\OdDbGeoMapPE. The main purpose of the OdDbGeoMapPE module is implementing the updateMapImage() method for updating geo-map objects.

Note: The updateMapImage() method works correctly only when using the WORLD-MERCATOR coordinate system for a geo-data entity and when OdDbGeoData::TypeOfCoordinates is not equal to kCoordTypLocal.

OdDbGeoMapPE module uses curl and tinyxml third-party libraries. The curl library is used for getting map images from the Internet (uses BING online service). To access the BING service, set your own BING-map key as a value of the sBingMapsKey global variable.

Note: The geo-data protocol extension object should be loaded for the OdDbGeoMapPE module work.

GeoCommands module implements commands for working with geo-data listed below:

  • GeoMap command changes the geo-map type for the current viewport (defined by GEOMAP variable).
  • GeoMapImage command creates the geo-map.
  • GeoMapImageSetMapType command changes the geo-map type of the created geo-map.
  • GeoMapImageSetResolution command changes the geo-map resolution.
  • GeoMapImageUpdate command updates the geo-map.

The GeoCommands module is located in Drawing\Examples\GeoCommands.

The third-party libraries, used in OdGeoData and OdDbGeoMapPE modules, are located in the .\ThirdParty folder. The csmap library implements coordinate system support and calculations. The curl library implements geo-map image updating. The tinyxml library is used for working with .xml-files.

A drawing that represents the results of GeolocationObj, OdGeoData, and OdDbGeoMapPE modules is below.

The background map comes from geo-data (geo-data drawing not implemented yet). The white border map is the OdDbGeoMap object. The red marker is a geolocation marker. The yellow marker is a geoposition marker.

Note: The csmap library should have access to a folder with the required dictionaries. All needed files are available in the CSDicts.zip archive located in the Thirdparty folder of the latest release on OdOutgoing. Go to https://www.opendesign.com/odoutgoing/LatestRelease/, navigate to the Thirdparty directory in the latest release version, and download CSDicts.zip. The dictionaries from the most recent release work with any Drawings SDK version. For all platforms, unzip the CSDicts folder and its contents, set the environment variable CS_MAP_DIR with the path to the CSDicts folder as its value. Another option for the Windows platform is to create a "CSDicts" folder in the application's directory (for example, exe\vc9dlldbg\CSDicts) and unzip the dictionary files to it.
For ODA members who have access to the Drawings Git repository, the required files are also available here: ThirdParty\csmap\Dictionaries.

Sample code of working with geo-data

Sample code that illustrates how to work with geo-data can be found in:

  • DbFiller::addGeoStuff() method of the OdWriteEx example
  • GeoMarkPosition command in the ExCommands module.
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.