Re: libchamplain with local (rails server + nominatim + tiles server ), add map source



Hi,

you don't need to register the map source (in fact, you can't, it's not possible with the public API) - you just need to create it and then use it. The mepbox.py demo is in principle what you need. With all the caching etc. the C version of the code which creates the map source should look something like this (I've only compiled the code and haven't tried it, hopefully it's alright):

static ChamplainMapSource *
create_cached_source (void)
{
  ChamplainMapSourceChain *source_chain;
  ChamplainMapSource *tile_source;
  ChamplainMapSource *error_source;
  ChamplainMapSource *memory_cache;
  ChamplainMapSource *file_cache;
  guint tile_size;
  ChamplainRenderer *renderer;

  ChamplainMapSourceFactory *factory = champlain_map_source_factory_dup_default();

  renderer = CHAMPLAIN_RENDERER (champlain_image_renderer_new ());
  tile_source = CHAMPLAIN_MAP_SOURCE(champlain_network_tile_source_new_full(
      "mapbox",
      "mapbox",
      "YOUR_LICENSE_TEXT",
      "YOUR_LICENSE_URI",
      0, //min zoom
      19, //max zoom
      256, //tile size
      CHAMPLAIN_MAP_PROJECTION_MERCATOR,
      renderer));

  tile_size = champlain_map_source_get_tile_size (tile_source);
  error_source = champlain_map_source_factory_create_error_source (factory, tile_size);

  renderer = CHAMPLAIN_RENDERER (champlain_image_renderer_new ());
  file_cache = CHAMPLAIN_MAP_SOURCE (champlain_file_cache_new_full (100000000, NULL, renderer));

  renderer = CHAMPLAIN_RENDERER (champlain_image_renderer_new ());
  memory_cache = CHAMPLAIN_MAP_SOURCE (champlain_memory_cache_new_full (100, renderer));

  source_chain = champlain_map_source_chain_new ();
  champlain_map_source_chain_push (source_chain, error_source);
  champlain_map_source_chain_push (source_chain, tile_source);
  champlain_map_source_chain_push (source_chain, file_cache);
  champlain_map_source_chain_push (source_chain, memory_cache);

  return CHAMPLAIN_MAP_SOURCE (source_chain);
}

and then call

champlain_view_set_map_source(your_champlain_view, create_cached_source());

Best regards,

Jiri



On Wed, Jan 23, 2019 at 9:55 AM romeo <romeo petruca perosoft org> wrote:


Found this
ChamplainMapSourceDesc *
champlain_map_source_desc_new_full (gchar *id,
                                    gchar *name,
                                    gchar *license,
                                    gchar *license_uri,
                                    guint min_zoom,
                                    guint max_zoom,
                                    guint tile_size,
                                    ChamplainMapProjection projection,
                                    gchar *uri_format,
                                    ChamplainMapSourceConstructor constructor,
                                    gpointer data);
and this
gboolean
champlain_map_source_factory_register (ChamplainMapSourceFactory *factory,
                                       ChamplainMapSourceDesc *desc);

but without an c example realy i can't resolve this.


-------- Forwarded Message --------
Subject: libchamplain with local (rails server + nominatim + tiles server ), add map source
Date: Wed, 23 Jan 2019 07:56:26 +0200
From: romeo <romeo petruca perosoft org>
To: libchamplain-list gnome org


Hi,

Need to work with libchamplain without internet access.

First solution libchamplain+memphis with OSM + rules.xml. 
(http://blog.mikeasoft.com/2010/09/24/local-map-rendering-and-route-finding-with-libchamplain-spatialite-and-open-street-map/)

Give up, is working but very very slow.

Second solution, instaled local rails server + nominatim + renderd(tiles 
server).

Http access: localhost:<port_number> local pc, or <ip_pc>:<port_number> 
local network.

Http access working great, no need internet access.

Now, how can i add a new source map to libchamplain in C.

Reading minimal.py from here 
(https://stackoverflow.com/questions/44607130/how-to-use-libchamplain-to-load-local-tiles-or-osm-xml-in-python), 
big diference

python and C.

A sample C example, how to add a new map source to libchamplain ?


_______________________________________________
libchamplain-list mailing list
libchamplain-list gnome org
https://mail.gnome.org/mailman/listinfo/libchamplain-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]