Changeset 85


Ignore:
Timestamp:
May 31, 2009, 1:02:34 AM (5 years ago)
Author:
simon
Message:

start of the map class implementation and renederer class enhancements

Location:
branches/client-library-split
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/client-library-split/memphis-map.c

    r83 r85  
    5353 
    5454static void 
     55memphis_map_dispose (GObject *object) 
     56{ 
     57  MemphisMap *self = MEMPHIS_MAP (object); 
     58 
     59  osmFree(self->map); 
     60  G_OBJECT_CLASS (memphis_map_parent_class)->dispose (object); 
     61} 
     62 
     63static void 
    5564memphis_map_class_init (MemphisMapClass *klass) 
    5665{ 
     
    6170  object_class->get_property = memphis_map_get_property; 
    6271  object_class->set_property = memphis_map_set_property; 
     72  object_class->dispose = memphis_map_dispose; 
    6373} 
    6474 
     
    6676memphis_map_init (MemphisMap *self) 
    6777{ 
     78  self->map = NULL; 
    6879} 
    6980 
    7081MemphisMap* 
    71 memphis_map_new (void) 
     82memphis_map_new_from_file (gchar* filename) 
    7283{ 
     84  MemphisMap* mmap = g_object_new (MEMPHIS_TYPE_MAP, NULL); 
     85  mmap->map = (osmFile *) osmRead(filename); 
     86  return mmap; 
     87} 
     88 
     89MemphisMap* 
     90memphis_map_new_from_data (gchar* data) 
     91{ 
     92  // TODO 
    7393  return g_object_new (MEMPHIS_TYPE_MAP, NULL); 
    7494} 
    7595 
     96void 
     97memphis_map_free (MemphisMap* map) 
     98{ 
     99  g_object_unref (G_OBJECT (map)); 
     100} 
  • branches/client-library-split/memphis-map.h

    r82 r85  
    2222 
    2323#include <glib-object.h> 
     24#include "osm05.h" 
    2425 
    2526G_BEGIN_DECLS 
     
    4445typedef struct { 
    4546  GObject parent; 
     47  osmFile *map; 
    4648} MemphisMap; 
    4749 
     
    5254GType memphis_map_get_type (void); 
    5355 
    54 MemphisMap* memphis_map_new (void); 
     56MemphisMap* memphis_map_new_from_file (gchar* filename); 
     57MemphisMap* memphis_map_new_from_data (gchar* data); 
     58void memphis_map_free (MemphisMap* map); 
    5559 
    5660G_END_DECLS 
  • branches/client-library-split/memphis-renderer.c

    r82 r85  
    3636struct _MemphisRendererPrivate 
    3737{ 
    38   GStringChunk *stringChunk; 
    39   GTree *stringTree; 
    40  
    4138  MemphisMap *map; 
    4239  MemphisRuleSet *rules; 
     
    7976  //rulesetFree(ruleset); 
    8077 
    81   //g_string_chunk_free(stringChunk);*/ 
     78  //g_string_chunk_free(stringChunk); 
    8279} 
    8380 
     
    132129memphis_renderer_set_map (MemphisRenderer *self, MemphisMap *map) 
    133130{ 
    134   g_return_if_fail (MEMPHIS_IS_RENDERER (self)); 
    135  
    136   MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
    137   priv->map = map; 
     131  g_return_if_fail (MEMPHIS_IS_RENDERER (self) && MEMPHIS_IS_MAP (map)); 
     132 
     133  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
     134  priv->map = g_object_ref (map); 
    138135} 
    139136 
     
    148145 
    149146void 
    150 memphis_renderer_set_rules_set (MemphisRenderer *self, MemphisRuleSet *rules) 
    151 { 
    152   g_return_if_fail (MEMPHIS_IS_RENDERER (self)); 
    153  
    154   MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
    155   priv->rules = rules; 
     147memphis_renderer_set_rules_set (MemphisRenderer *self, 
     148    MemphisRuleSet *rules) 
     149{ 
     150  g_return_if_fail (MEMPHIS_IS_RENDERER (self) && 
     151      MEMPHIS_IS_RULESET (rules)); 
     152 
     153  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
     154  priv->rules = g_object_ref (rules); 
    156155} 
    157156 
     
    171170  MemphisRenderer *self = MEMPHIS_RENDERER (object); 
    172171  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
    173  
    174   g_tree_destroy(priv->stringTree); 
    175   g_string_chunk_free(priv->stringChunk); 
    176172 
    177173  g_object_unref (G_OBJECT (priv->map)); 
     
    196192{ 
    197193  MemphisRenderer *self = MEMPHIS_RENDERER (object); 
     194  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
    198195  switch (property_id) 
    199196    { 
    200197      case PROP_RESOLUTION: 
    201         g_value_set_uint (value, memphis_renderer_get_resolution (self)); 
     198        g_value_set_uint (value, priv->resolution); 
    202199        break; 
    203200      case PROP_ZOOM_LEVEL: 
    204         g_value_set_uint (value, memphis_renderer_get_zoom_level (self)); 
     201        g_value_set_uint (value, priv->zoom_level); 
    205202        break; 
    206203      case PROP_MAP: 
    207         g_value_set_object (value, memphis_renderer_get_map (self)); 
     204        g_value_set_object (value, priv->map); 
    208205        break; 
    209206      case PROP_RULE_SET: 
    210         g_value_set_object (value, memphis_renderer_get_rule_set (self)); 
     207        g_value_set_object (value, priv->rules); 
    211208        break; 
    212209      default: 
     
    226223      case PROP_RESOLUTION: 
    227224        memphis_renderer_set_resolution (self, g_value_get_uint (value)); 
     225        break; 
     226      case PROP_ZOOM_LEVEL: 
     227        memphis_renderer_set_zoom_level (self, g_value_get_uint (value)); 
     228        break; 
     229      case PROP_MAP: 
     230        memphis_renderer_set_map (self, g_value_get_object (value)); 
     231        break; 
     232      case PROP_RULE_SET: 
     233        memphis_renderer_set_rules_set (self, g_value_get_object (value)); 
    228234        break; 
    229235      default: 
     
    314320{ 
    315321  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
    316   priv->stringChunk = g_string_chunk_new (265); 
    317   priv->stringTree = g_tree_new (m_tree_strcmp); 
    318322  priv->resolution = 256; 
    319323  priv->zoom_level = 12; 
Note: See TracChangeset for help on using the changeset viewer.