GeocItem

GeocItem — A homogenous group of geographically referenced canvas items.

Synopsis

                    GeocItem;
GeocItem*           geoc_item_new                       (GeocItem *parent,
                                                         GType type,
                                                         const gchar *first_arg_name,
                                                         ...);
void                geoc_item_begin                     (GeocItem *item);
CrItem*             geoc_item_add_point                 (GeocItem *item,
                                                         double lon,
                                                         double lat,
                                                         const gchar *first_arg_name,
                                                         ...);
CrItem*             geoc_item_end_segment               (GeocItem *item,
                                                         const gchar *first_arg_name,
                                                         ...);
void                geoc_item_end                       (GeocItem *item);
void                geoc_item_request_update            (GeocItem *item);
void                geoc_item_invoke_rebuild_g2w        (GeocItem *item,
                                                         GeocProjection *projection,
                                                         gboolean required);
void                geoc_item_invoke_clip               (GeocItem *item,
                                                         double cx1,
                                                         double cy1,
                                                         double cx2,
                                                         double cy2,
                                                         gboolean viewport_changed);
void                geoc_item_set_absorbed_property     (GeocItem *item,
                                                         guint property_id,
                                                         const GValue *value,
                                                         GParamSpec *pspec);
void                geoc_item_get_absorbed_property     (GeocItem *item,
                                                         guint property_id,
                                                         GValue *value,
                                                         GParamSpec *pspec);
void                geoc_item_init_absorbed_properties  (GeocItem *item);
void                geoc_item_class_absorb_properties   (GeocItemClass *parent,
                                                         GObjectClass *child,
                                                         const char *first_glob,
                                                         ...);
void                geoc_item_apply_absorbed_properties (GeocItem *parent,
                                                         CrItem *child);

Object Hierarchy

  GObject
   +----CrItem
         +----GeocItem
               +----GeocPlaces
               +----GeocLines
               +----GeocLinesFaster
               +----GeocShapes
               +----GeocGrids

Properties

  "itemtype"                 guint                 : Read / Write
  "maxx"                     gdouble               : Read
  "maxy"                     gdouble               : Read
  "minx"                     gdouble               : Read
  "miny"                     gdouble               : Read

Description

This class provides a common interface for building various types of canvas items from geographic points. It also acts as a grouping class for any item tree that is to be used with GeocCanvas. This item should be used wherever you would normally use a CrItem.

Use the begin, add_point, end_segment, and end methods to add children that are referenced to geographic points.

This example draws a rectangle onto the canvas:

GeocItem *group;

group = geoc_item_new(parent, GEOC_TYPE_LINES,
        "itemtype", CR_TYPE_LINE,
        "fill_color", "red", NULL);

geoc_item_begin(group);
geoc_item_add_point(group, -71.5, 41.0);
geoc_item_add_point(group, -71.0, 41.0);
geoc_item_add_point(group, -71.0, 40.5);
geoc_item_add_point(group, -71.5, 40.5);
geoc_item_end_segment(group);
geoc_item_end(group);

This example draws four distinct '*' points onto the canvas:

GeocItem *group;
GObject *object;

group = geoc_item_new(parent, GEOC_TYPE_PLACES,
        "itemtype", CR_TYPE_TEXT,
        "text", "*",
        "fill_color", "red", NULL);

geoc_item_begin(group);
geoc_item_add_point(group, -71.5, 41.0);
geoc_item_add_point(group, -71.0, 41.0);
geoc_item_add_point(group, -71.0, 40.5);
geoc_item_add_point(group, -71.5, 40.5);
geoc_item_end(group);

Details

GeocItem

typedef struct {
        gint flags;
} GeocItem;


geoc_item_new ()

GeocItem*           geoc_item_new                       (GeocItem *parent,
                                                         GType type,
                                                         const gchar *first_arg_name,
                                                         ...);

A factory that creates a new geo canvas item with parent as its parent item. The type argument should be something like GEOC_TYPE_LINES, GEOC_TYPE_PLACES, or GEOC_TYPE_SHAPES. Any known properties for the type that gets created may be passed into the variable argument list. To create a simple grouping item, use type = GEOC_TYPE_ITEM.

parent :

The parent item for the new item.

type :

The object type of the item.

first_arg_name :

A list of object argument name/value pairs, NULL-terminated, used to configure the item.

... :

Returns :

The newly-created item. You must call g_object_ref if you intend to use this reference outside the local scope.

geoc_item_begin ()

void                geoc_item_begin                     (GeocItem *item);

This will clear out any existing items in the group and start with a clean list.

item :


geoc_item_add_point ()

CrItem*             geoc_item_add_point                 (GeocItem *item,
                                                         double lon,
                                                         double lat,
                                                         const gchar *first_arg_name,
                                                         ...);

This will either add a new place canvas item or will add a new point to a polygon or line that is being built. In the former case a reference to the canvas item is returned.

item :

lon :

The longitude of the new point.

lat :

The latitude of the new point.

first_arg_name :

A list of object argument name/value pairs, NULL-terminated, used to configure the item. If no item is created, the name/value pairs are ignored.

... :

Returns :

A pointer to a canvas item or NULL if this is a line or a polygon. You must call g_object_ref if you intend to use this reference outside the local scope.

geoc_item_end_segment ()

CrItem*             geoc_item_end_segment               (GeocItem *item,
                                                         const gchar *first_arg_name,
                                                         ...);

This ends a logical segment. For a place item it does nothing. For a line item, it tells the object that the line is finished being constructed.

item :

first_arg_name :

A list of object argument name/value pairs, NULL-terminated, used to configure the item. If no item is created, the name/value pairs are ignored.

... :

Returns :

A valid reference to a canvas item for polygons or lines or NULL for a point object. You must call g_object_ref if you intend to use this reference outside the local scope.

geoc_item_end ()

void                geoc_item_end                       (GeocItem *item);

This tells the object that all of the data has been added and it is OK to draw the data.

item :


geoc_item_request_update ()

void                geoc_item_request_update            (GeocItem *item);

Works like cr_item_request_update, but also sets the GEOC_ITEM_NEED_REBUILD_G2W flag. This ensures that the geographic references get recomputed into item coordinates during the next update cycle.

item :


geoc_item_invoke_rebuild_g2w ()

void                geoc_item_invoke_rebuild_g2w        (GeocItem *item,
                                                         GeocProjection *projection,
                                                         gboolean required);

The routine is used internally. It is called by the canvas device.

item :

projection :

The projection used to recompute.

required :

TRUE if it is necessary for all items to recompute.

geoc_item_invoke_clip ()

void                geoc_item_invoke_clip               (GeocItem *item,
                                                         double cx1,
                                                         double cy1,
                                                         double cx2,
                                                         double cy2,
                                                         gboolean viewport_changed);

The routine is used internally. It is called by the canvas device.

item :

cx1 :

Left side.

cy1 :

Top side.

cx2 :

Right side.

cy2 :

Bottom side.

viewport_changed :

If the viewport has changed since the last time this was called.

geoc_item_set_absorbed_property ()

void                geoc_item_set_absorbed_property     (GeocItem *item,
                                                         guint property_id,
                                                         const GValue *value,
                                                         GParamSpec *pspec);

GeocItem implementations should call this from their set_property methods if they called absorbed_properties from their class_init functions. It saves the new property setting in the item's hash table, then applies the property to each of the item's children, but only after verifying that the item has the property. Property values saved in the item's hash table are applied to items that are added later.

item :

property_id :

value :

pspec :


geoc_item_get_absorbed_property ()

void                geoc_item_get_absorbed_property     (GeocItem *item,
                                                         guint property_id,
                                                         GValue *value,
                                                         GParamSpec *pspec);

GeocItem implementations should call this from their get_property methods if they called absorbed_properties from their class_init functions. It sets the property from the GeocItem's internal hash table storage.

item :

property_id :

value :

pspec :


geoc_item_init_absorbed_properties ()

void                geoc_item_init_absorbed_properties  (GeocItem *item);

This routine is used by GeocItem implementations. It needs to be called from the object init routine for each derived class that calls geoc_item_class_absorb_properties from its class_init routine.

item :


geoc_item_class_absorb_properties ()

void                geoc_item_class_absorb_properties   (GeocItemClass *parent,
                                                         GObjectClass *child,
                                                         const char *first_glob,
                                                         ...);

Interrogates child to find properties which glob match the input string. Any properties that match will be installed into the parent class if they don't already exist in the parent. This should be called from the class_init method of GeocItem implementations that will contain CrItems.

parent :

child :

The class to take the properties from.

first_glob :

... :

As many patternes as needed must be NULL terminated.

geoc_item_apply_absorbed_properties ()

void                geoc_item_apply_absorbed_properties (GeocItem *parent,
                                                         CrItem *child);

This is normally only called by GeocItem implementations. It is called by default whenever a child is added to a GeocItem group.

parent :

The item which has the desired property settings.

child :

The item to apply the properties to.

Property Details

The "itemtype" property

  "itemtype"                 guint                 : Read / Write

Canvas item type for each member in the group. Items of this type will get instantiated as necessary when add_point and end_segment functions are called.

Default value: 0


The "maxx" property

  "maxx"                     gdouble               : Read

Maximum X Extent.

Default value: 0


The "maxy" property

  "maxy"                     gdouble               : Read

Maximum Y Extent.

Default value: 0


The "minx" property

  "minx"                     gdouble               : Read

Minimum X Extent.

Default value: 0


The "miny" property

  "miny"                     gdouble               : Read

Minimum Y Extent.

Default value: 0

See Also

GeocLines, GeocPlaces, GeocLinesFaster