Jump to: navigation, search

Installing LibreMap on Ubuntu 16.04

Fresh installation on Ubuntu Xenial 16.04.

  • Please note this is a work in progress. I still have not figured out how to get nodes to display on LibreMap.

This guide is based on a very helpful guide at https://wiki.reseaulibre.ca/documentation/libremap/installation/ accommodating some anomalies I found carrying out the installation:

Preparation

enable source URIs in /etc/apt/sources.list then

   sudo apt-get update
   sudo apt-get install build-essential erlang libicu-dev libmozjs-24-dev  libcurl4-openssl-dev libtool automake checkinstall couchdb 
   mkdir ~/src

Install couchdb source

   cd ~/src
   sudo apt-get source couchdb

Download geocouch source, compile and install

   git clone https://github.com/couchbase/geocouch.git
   cd ~/src/geocouch/
   export COUCH_SRC=~/src/couchdb-1.6.0/src/couchdb
   git checkout couchdb1.3.x
   make
   sudo cp -r ebin /usr/local/lib/couchdb-geocouch
   export ERL_FLAGS="-pa /usr/local/lib/couchdb-geocouch"
   sudo service couchdb restart

Libremap-api Installation

Install requirements

   sudo apt-get install nodejs npm
   sudo ln -s /usr/bin/nodejs /usr/bin/node
   sudo npm install -g grunt-cli

Install libremap api

   cd ~/src/
   git clone git://github.com/libremap/libremap-api.git
   cd libremap-api
   npm install

Browse to http://localhost:5984/_utils/index.html If the web pages comes up, all is well. Click on Verify Installation at the left. Create an admin account by clicking at the lower right corner.

Create a file couch.json in ~/src/libremap-api with something like the following, replacing localhost with IP address of server you are working on if not working locally on your computer.

{
  "couches": {
    "localhost": {
      "database": "http://localhost:5984/libremap"
    },
    "dev": {
      "database": "http://localhost:5984/libremap-dev",
      "user": "libremap-dev",
      "pass": "somerandompassword"
    },
    "production": {
      "database": "http://localhost:5984/libremap",
      "user": "libremap",
      "pass": "anotherrandompassword"
    }
  }
}

Make sure the user and password match the admin account that you set up.

   grunt push --couch dev

Libremap Web UI

Install requirements

   sudo npm install -g bower

Install libremap-webui

   cd ~/src/
   git clone git://github.com/libremap/libremap-webui.git
   cd libremap-webui
   npm install
   bower install

Configure local settings

   cp -i config.json.example config.json

This is what I currently have in config.json. I am not sure whether the api url is correct or whether it should be something more like http://localhost:5984/libremap-dev/_design/libremap-api/_rewrite/router/ Neither seem to work in updating the map.

{
  "api_url": "http://localhost:5984/api",
  "title": "Home Network",
  "init_bbox": [[-60,-180],[75,180]],
  "plugins": {
    "tileLayer": "./plugins/tileLayer",
    "tileLayerBing": "./plugins/tileLayerBing",
    "lmLayer": "./plugins/lmLayer/index",
    "lmFilterRouterAP": "./plugins/lmLayer/filters/routerAP",
    "lmFilterRouterCommunity": "./plugins/lmLayer/filters/routerCommunity",
    "lmFilterRouterLastUpdate": "./plugins/lmLayer/filters/routerLastUpdate",
    "lmFilterLinkDistanceMax": "./plugins/lmLayer/filters/linkDistanceMax",
    "lmFilterLinkQualityMin": "./plugins/lmLayer/filters/linkQualityMin"
  },
  "TODO": {
    "lmFilterLinkType": "./plugins/libremapLayer/filters_links/type"
  },
  "baseLayers": {
    "active_id": "osm_standard",
    "layers": [
      {
        "plugin": "tileLayer",
        "id": "osm_standard",
        "name": "OSM Standard",
        "url": "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
        "options": {
          "attribution": "Map data © <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>"
        }
      },
      {
        "plugin": "tileLayerBing",
        "id": "bing_satellite",
        "name": "Bing satellite",
        "key": "ArewtcSllazYp52r7tojb64N94l-OrYWuS1GjUGeTavPmJP_jde3PIdpuYm24VpR",
        "options": {
          "minZoom": 1
        }
      }
    ]
  },

  "dataLayers": [
    {
      "plugin": "lmLayer",
      "id": "home",
      "name": "Routers and Links",
      "api_url": "http://localhost:5984/api",
      "fine_max": 200,
      "show_routers": true,
      "routers": {
        "cluster": true,
        "filter_mode": "or",
        "filters": [
          {
            "plugin": "lmFilterRouterLastUpdate",
            "enabled": true,
            "name": "Time since update (days)",
            "val": 7
          },
          {
            "plugin": "lmFilterRouterAP",
            "enabled": false,
            "name": "Access points"
          },
          {
            "plugin": "lmFilterRouterCommunity",
            "enabled": false,
            "name": "Community",
            "val": "Freifunk Berlin"
          }
        ]
      },
      "show_links": true,
      "links": {
        "filter_mode": "and",
        "filters": [
          {
            "plugin": "lmFilterLinkDistanceMax",
            "enabled": true,
            "name": "Maximum distance (m)",
            "val": 50000
          },
          {
            "plugin": "lmFilterLinkQualityMin",
            "enabled": true,
            "name": "Minimum quality (0-1)",
            "val": 0.5
          }
        ],
        "TODO": [
          {
            "plugin": "lmLinkFilterType",
            "enabled": false,
            "name": "Type",
            "val": "batman"
          },
          {
            "plugin": "distance_min",
            "enabled": false,
            "name": "Minimum distance (m)",
            "val": 0
          },
          {
            "plugin": "quality_max",
            "enabled": true,
            "name": "Maximum quality",
            "val": 1
          }
        ]
      }
    }
  ]
}

Creating a node

Create a text file for a node (e.g. node1.json) you wish to add to the network, e.g.

{
  "api_rev": "1.0",
  "type": "router",
  "ctime": "2013-08-20T19:00:00.000Z",
  "mtime": "2013-12-10T19:00:00.000Z",
  "hostname": "latakia",
  "lat": 45.465676,
  "lon": -73.572185,
  "community": "Réseau libre/Montréal"
}
I am giving the example from ReseauLibre because I still haven't figured the syntax out for batman-adv
   $ curl -X POST -d @node1.json http://localhost:5984/libremap-dev/_design/libremap-api/_rewrite/router/

It should respond:

   {"ok":true,"id":"e31ac2d003d2ef25b3d241ff92000f3a"}

We can then query the server to see if it worked. Substitute the id from above in the command below.

   curl -X GET http://localhost:5984/libremap-dev/_design/libremap-api/_rewrite/router/e31ac2d003d2ef25b3d241ff92000f3a

It should print the equivalent of what was saved.

I get this far but the nodes that I am added do not appear on the libremap UI. More documentation on the json file format is available at https://github.com/libremap/libremap-api/blob/master/doc-api-router.md#json-example