GLG Toolkit, C / C++ API Library  Version 4.6

This group contains functions that may be used for handling coordinate conversions and GIS queries when a GLG GIS Object is used to display a map inside the GLG drawing. More...

Detailed Description

This group contains functions that may be used for handling coordinate conversions and GIS queries when a GLG GIS Object is used to display a map inside the GLG drawing.

Functions

GlgBoolean GlgGISConvert (GlgObject object, char *resource_name, GlgCoordType coord_type, GlgBoolean coord_to_lat_lon, GlgPoint *in_point, GlgPoint *out_point)
 Performs coordinate conversion from the GIS coordinates of the GIS Object to the GLG coordinates of the drawing and visa versa. More...
 
GlgObject GlgGISCreateSelection (GlgObject object, char *resource_name, char *layers, GlgLong x, GlgLong y, GlgLong select_labels)
 Returns a message object containing information about GIS features located at a specified position on the map. More...
 
GlgObject GlgGISGetDataset (GlgObject object, char *resource_name)
 Returns a dataset object associated with the GIS Object. More...
 
GlgBoolean GlgGISGetElevation (GlgObject object, char *resource_name, char *layer_name, double lon, double lat, double *elevation)
 Returns an elevation of a lat/lon point on a map. More...
 
void GlmConvert (GlgProjectionType projection, GlgBoolean stretch, GlgCoordType coord_type, GlgBoolean coord_to_lat_lon, GlgPoint *center, GlgPoint *extent, double angle, double min_x, double max_x, double min_y, double max_y, GlgPoint *in_point, GlgPoint *out_point)
 A low level function that performs coordinate conversion from the GIS coordinates of a map to the GLG coordinates of the drawing and visa versa without the help of a GLG GIS Object. More...
 

Function Documentation

◆ GlgGISConvert()

GlgBoolean GlgGISConvert ( GlgObject  object,
char *  resource_name,
GlgCoordType  coord_type,
GlgBoolean  coord_to_lat_lon,
GlgPoint in_point,
GlgPoint out_point 
)

Performs coordinate conversion from the GIS coordinates of the GIS Object to the GLG coordinates of the drawing and visa versa.

Parameters
object
  • If resource_name is NULL, specifies the GIS Object whose coordinate system to use for conversion.
  • If resource_name is not NULL, specifies a parent of the GIS Object.
resource_nameIf not NULL, specifies the resource path of the GIS Object inside the parent object specified by the object parameter.
coord_typeThe type of the GLG coordinate system to convert to or from:
coord_to_lat_lon
  • True to convert from GLG coordinates to GIS longitude and latitude
  • False to convert the GIS longitude and latitude to GLG coordinates.
in_pointA pointer to the GlgPoint structure containing coordinate values to be converted.
out_pointA pointer to the GlgPoint structure that will receive converted coordinate values (x/y in the selected coordinate system or lon/lat)
Returns
Success or failure status.

When converting from X/Y to lat/lon coordinates in the ORTHOGRAPHIC projection, the Z coordinate is set to a negative value for points on the invisible part of the globe or outside the globe area, and to zero for points on the edge of the globe. Coordinates of the returned point may be outside of the visible portion of the map for all projections.

This function performs coordinate conversion using the current settings of the GIS object, which must be setup and rendered.

The GlmConvert function may be used to perform coordinate conversion between GIS and GLG coordinates without the use of the GIS object, which could be done before the drawing is rendered, without a drawing at all, or without a GIS object being present.

◆ GlgGISCreateSelection()

GlgObject GlgGISCreateSelection ( GlgObject  object,
char *  resource_name,
char *  layers,
GlgLong  x,
GlgLong  y,
GlgLong  select_labels 
)

Returns a message object containing information about GIS features located at a specified position on the map.

This function provides a high-level interface to the map server's GlmGetSelection function and may be used to query GIS selection at the point selected by the mouse click.

Parameters
object
  • If resource_name is NULL, specifies the GIS Object whose coordinate system to use for conversion.
  • If resource_name is not NULL, specifies a parent of the GIS Object.
resource_nameIf not NULL, specifies the resource path of the GIS Object inside the parent object specified by the object parameter.
layersA list of layers to query.
x,yCoordinates of a point in the screen coordinates of a viewport that contains the GIS object.
select_labelsSpecifies the label selection mode, can have the following values (defined in the GlmLabelSelectionMode enum in the GlmApi.h file):
  • GLM_LBL_SEL_NONE - GIS features' labels are not considered for the GIS selection.
  • GLM_LBL_SEL_IN_TILE_PRECISION - enables labels to be considered for the GIS selection. For a faster selection, this option does not check labels that belong to GIS features in a different tile but extend to the current tile.
  • GLM_LBL_SEL_MAX_PRECISION - enables labels to be considered for the GIS selection and performs selection with the maximum label precision.

    The layer's settings have precedence over the select_labels parameter. The labels will be considered for selection only for the layers that do not override it by setting their LABEL SELECTION MODE=NONE in the layer's LIF file. If LABEL SELECTION MODE=INTILE, the labels will always be considered using the IN_TILE precision.
Returns
A message object containing information about the selected GIS features. The message object has to be dereferenced using GlgDropObject when finished.

If the GIS verbosity level is set to 2000 or 2001, extended information is also written to the error log file and printed to the terminal on Linux/Unix for debugging purposes.

Refer to the GlmGetSelection section of the GLG Map Server Reference Manual for information on the structure of the returned message object as well as a programming example that demonstrates how to handle it.

◆ GlgGISGetDataset()

GlgObject GlgGISGetDataset ( GlgObject  object,
char *  resource_name 
)

Returns a dataset object associated with the GIS Object.

The function may be invoked after the GIS Object has been set up to retrieve its dataset. The dataset may be used to dynamically change attributes of individual layers displayed in the GIS Object. The program can use SetResourcefunctions for changing layer attributes. Refer to the GLG Map Server Reference Manual for information on layer attributes. The GLG GIS Demo provides an example of changing layer attributes programmatically.

Parameters
object
  • If resource_name is NULL, specifies the GIS Object whose coordinate system to use for conversion.
  • If resource_name is not NULL, specifies a parent of the GIS Object.
resource_nameIf not NULL, specifies the resource path of the GIS Object inside the parent object specified by the object parameter.
Returns
A dataset object.

◆ GlgGISGetElevation()

GlgBoolean GlgGISGetElevation ( GlgObject  object,
char *  resource_name,
char *  layer_name,
double  lon,
double  lat,
double *  elevation 
)

Returns an elevation of a lat/lon point on a map.

Parameters
object
  • If resource_name is NULL, specifies the GIS Object whose coordinate system to use for conversion.
  • If resource_name is not NULL, specifies a parent of the GIS Object.
resource_nameIf not NULL, specifies the resource path of the GIS Object inside the parent object specified by the object parameter.
layer_nameThe name of the layer with elevation data to query.
lon,latThe lon/lat coordinates of a point on the map.
elevationA pointer to the variable of a double type that will receive the returned elevation data.
Returns
  • False if the point is outside of the map in the ORTHOGRAPHIC projection, or if there is no elevation data for the specified location.
  • True, if the elevation value is returned.

This function may be used to query elevation at the point selected by the mouse click.

The returned value is in the units (such as meters or feet) defined by the elevation data file.

◆ GlmConvert()

void GlmConvert ( GlgProjectionType  projection,
GlgBoolean  stretch,
GlgCoordType  coord_type,
GlgBoolean  coord_to_lat_lon,
GlgPoint center,
GlgPoint extent,
double  angle,
double  min_x,
double  max_x,
double  min_y,
double  max_y,
GlgPoint in_point,
GlgPoint out_point 
)

A low level function that performs coordinate conversion from the GIS coordinates of a map to the GLG coordinates of the drawing and visa versa without the help of a GLG GIS Object.

Since the function does not rely on a GIS Object being displayed and set up, it may be used before the drawing is rendered, without a drawing at all, or without a GIS object being present.

When converting from X/Y to lat/lon coordinates in the ORTHOGRAPHIC projection, the Z coordinate is set to a negative value for points on the invisible part of the globe or outside the globe area, and to zero for points on the edge of the globe. Coordinates of the returned point may be outside of the visible portion of the map for all projections.

Parameters
projectionA GIS map projection: GLG_RECTANGULAR_PROJECTION or GLG_ORTHOGRAPHIC_PROJECTION.
stretchSpecifies if the map preserves the X/Y ratio (False) or not (True).
coord_typeThe type of the GLG coordinate system to convert to or from:
coord_to_lat_lon
  • True to convert from GLG coordinates to GIS longitude and latitude
  • False to convert from GIS longitude and latitude to GLG coordinates.
centerA pointer to the GlgPoint structure containing lat/lon coordinates of the map center. The Z coordinate must be set to 0.
extentA pointer to the GlgPoint structure containing X and Y extent of the map in the selected projection: in degrees for the RECTANGULAR projection or in meters for ORTHOGRAPHIC. The Z extent must be set to 0. Refer to the GIS Object section of the GLG User's Guide and Builder Reference Manual for more details.
angleA map rotation angle in degrees.
min_x,max_x,min_y,max_yA map extent in the selected coordinate system. To get X/Y coordinates relative to the map image origin, use min_x=0, min_y=0, max_x=image_width, max_y=image_height.
in_pointA pointer to the GlgPoint structure containing coordinate values to be converted (x/y in the selected coordinate system or lon/lat).
out_pointA pointer to the GlgPoint structure that will receive converted coordinate values (x/y in the selected coordinate system or lon/lat).