GeoProjection

GeoProjection — provides conversion services between 'geo' coordinates and 'world' coordinates.

Synopsis




            GeoProjectionPrivate;
            GeoProjectionClassPrivate;
            GeoProjection;
            GeoProjectionClass;
gboolean    geo_projection_g2w              (GeoProjection *projection,
                                             double lon,
                                             double lat,
                                             double *wx,
                                             double *wy);
gboolean    geo_projection_w2g              (GeoProjection *projection,
                                             double wx,
                                             double wy,
                                             double *lon,
                                             double *lat);
gboolean    geo_projection_g2w_i            (GeoProjection *projection,
                                             int lon,
                                             int lat,
                                             double *wx,
                                             double *wy);
gboolean    geo_projection_w2g_i            (GeoProjection *projection,
                                             double wx,
                                             double wy,
                                             int *lon,
                                             int *lat);
const GList* geo_projection_get_available_projections
                                            (void);

Object Hierarchy


  GObject
   +----GeoProjection

Properties


  "cylindrical"          gboolean              : Read
  "geoproj"              gpointer              : Read / Write
  "hemisphere"           gboolean              : Read
  "projstring"           gchararray            : Read / Write
  "reference"            gpointer              : Read / Write
  "reflat"               gdouble               : Read / Write
  "reflon"               gdouble               : Read / Write
  "rotation"             gpointer              : Read / Write
  "rotdeg"               gdouble               : Read / Write

Signal Prototypes


"projection-changed"
            void        user_function      (GeoProjection *geoprojection,
                                            gpointer user_data);

Description

The GeoProjection object is basically a high level GObject wrapper around the tkgeomap geography and geoProj native code. It provides conversion services between 'geo' and 'world' coordinates and acts as a controller for a given canvas and canvas items. For the most part, this object should be sufficient for doing basic coordinate conversion; however, for more complex operations the tkgeomap native code should be used.

Several components of the tkgeomap project have been included in this project, but they have not been documented here because they are well documented by the tkgeomap project. Man pages for these components are available at this project's homepage.

The below example uses GeoProjection to convert cursor position to longitude and latitude:


double wx, wy, lon, lat;

foo_canvas_window_to_world(canvas, event->motion.x, event->motion.y, 
        38;wx, 38;wy);

geo_projection_w2g(projection, wx, wy, 38;lon, 38;lat);

Details

GeoProjectionPrivate

typedef struct _GeoProjectionPrivate GeoProjectionPrivate;

The GeoProjectionPrivate-struct contains private data only and should be accessed via the properties interface of this object.


GeoProjectionClassPrivate

typedef struct _GeoProjectionClassPrivate GeoProjectionClassPrivate;


GeoProjection

typedef struct _GeoProjection GeoProjection;


GeoProjectionClass

typedef struct {
        GObjectClass parent_class;

        GeoProjectionClassPrivate *private;

        /* Signals go here */

        /**
         * projection_changed:
         * @projection:
         * 
         * This signal is emitted once after a G_PRIORITY_HIGH_IDLE time when
         * any one or more properties of the GeoProjection object have been
         * changed.  Canvas Items should connect to the projection_changed
         * signal from the GeoCanvas, not from here. 
         **/
        void (*projection_changed)(GeoProjection *projection);
} GeoProjectionClass;


geo_projection_g2w ()

gboolean    geo_projection_g2w              (GeoProjection *projection,
                                             double lon,
                                             double lat,
                                             double *wx,
                                             double *wy);

This procedure converts geographic coordinates to canvas world coordinates based on the current projection, reference, and rotation.

projection :
lon : Geographic longitude in degrees.
lat : Geographic latitude in degrees.
wx : Canvas world coordinates returned.
wy : Canvas world coordinates returned.
Returns : False if the geo point cannot be displayed by this projection.

geo_projection_w2g ()

gboolean    geo_projection_w2g              (GeoProjection *projection,
                                             double wx,
                                             double wy,
                                             double *lon,
                                             double *lat);

This procedure converts canvas world coordinates coordinates to geographic coordinates based on the current projection, reference, and rotation.

projection :
wx : Canvas world coordinates returned.
wy : Canvas world coordinates returned.
lon : Geographic longitude in degrees.
lat : Geographic latitude in degrees.
Returns : True only if there is a valid geo-point for this world point.

geo_projection_g2w_i ()

gboolean    geo_projection_g2w_i            (GeoProjection *projection,
                                             int lon,
                                             int lat,
                                             double *wx,
                                             double *wy);

This procedure converts geographic coordinates to canvas world coordinates based on the current projection, reference, and rotation. Geographic coordinates are in integer Angle format as is native to tkGeomap.

projection :
lon : Geographic longitude in geography Angle representation.
lat : Geographic latitude in geography Angle representation.
wx : Canvas world coordinates returned.
wy : Canvas world coordinates returned.
Returns : False if the geo point cannot be displayed by this projection.

geo_projection_w2g_i ()

gboolean    geo_projection_w2g_i            (GeoProjection *projection,
                                             double wx,
                                             double wy,
                                             int *lon,
                                             int *lat);

This procedure converts canvas world coordinates coordinates to geographic coordinates based on the current projection, reference, and rotation. Geographic coordinates are in integer Angle format as is native to tkGeomap.

projection :
wx : Canvas world coordinates returned.
wy : Canvas world coordinates returned.
lon : Geographic longitude in geography Angle representation.
lat : Geographic latitude in geography Angle representation.
Returns : True only if there is a valid geo-point for this world point.

geo_projection_get_available_projections ()

const GList* geo_projection_get_available_projections
                                            (void);

This procedure returns a reference to the head of the linked list containing all of the available projection name strings. It can be used to fill the fields of a combo box.

Returns : GList containing the available projection name strings.

Properties

The "cylindrical" property

  "cylindrical"          gboolean              : Read

A flag to indicate if this is a cylindrical projection. Cylindrical projections are characterized by rectangular maps that are capable of showing most or all of the world at once.

Default value: TRUE


The "geoproj" property

  "geoproj"              gpointer              : Read / Write

This is a pointer to the tkgeomap geoProj structure. This structure does not support reference counting, so the user of this property should assume that the GeoProjection will take over lifecycle management of the geoProj.


The "hemisphere" property

  "hemisphere"           gboolean              : Read

A flag to indicate if this is a hemispheric projection. Hemispheric projections show only 1/2 of the Earth defined from a particular reference point.

Default value: TRUE


The "projstring" property

  "projstring"           gchararray            : Read / Write

This is a string description of the currently selected projection. It can be used to change the projection provided the correct string representation is given. Available projections can be queried via geo_projection_get_available_projections().

Default value: "Mercator"


The "reference" property

  "reference"            gpointer              : Read / Write

This is the projection's reference point as represented by the tkgeomap native GeoPt native structure. The reference point can also be changed using the primitive reflon and reflat properties.


The "reflat" property

  "reflat"               gdouble               : Read / Write

This is the latitude of the projection's reference point. It has no effect on cylindrical projection's, but should be set anyway in case the user should decide to subsequently switch to a hemispheric projection.

Allowed values: [-90,90]

Default value: 0


The "reflon" property

  "reflon"               gdouble               : Read / Write

This is the longitude of the projection's reference point.

Allowed values: [-360,360]

Default value: 0


The "rotation" property

  "rotation"             gpointer              : Read / Write

Rotation of the map.


The "rotdeg" property

  "rotdeg"               gdouble               : Read / Write

Rotation in degrees.

Allowed values: [0,360]

Default value: 0

Signals

The "projection-changed" signal

void        user_function                  (GeoProjection *geoprojection,
                                            gpointer user_data);

This signal is emitted once after a G_PRIORITY_HIGH_IDLE time when any one or more properties of the GeoProjection object have been changed. Canvas Items should connect to the projection_changed signal from the GeoCanvas, not from here.

geoprojection : the object which received the signal.
user_data : user data set when the signal handler was connected.