SimpleGraph-Tutorial/Geo

From BITPlan Wiki
Jump to navigation Jump to search
OsProject
id  com.bitplan.simplegraph-tutorial-geo
state  
owner  BITPlan
title  SimpleGraph Geo Tutorial
url  https://github.com/BITPlan/com.bitplan.simplegraph-tutorial-geo
version  0.0.1
description  
date  
since  
until  

SimpleGraph Geo Showcase

Openly available Geographic data from different APIs seems to be a good basis for showcasing the SimpleGraph approach.

Charging Stations example

We'd like to gather data on Charging stations from different sources:

  1. Bundesnetzagentur (Excel File)
  2. Openstreetmap (API)
  3. OpenchargeMap (API)

First step: Loading data from Bundesnetzagentur

The ChargingStation Map of Bundesnetzagentur is based on the Date from the Excel file Download

Let's read it with our SimpleGraph-Excel Module.

package com.bitplan.simplegraph.geotutorial;

import static org.junit.Assert.assertEquals;

import java.io.File;

import org.junit.Test;

import com.bitplan.simplegraph.core.SimpleNode;
import com.bitplan.simplegraph.excel.ExcelSystem;

public class TestChargingStations {

  boolean debug = true;

  /**
   * test reading the list of registered german charging stations from
   * Bundesnetzagentur
   * 
   * @throws Exception
   */
  @Test
  public void testBundesnetzagentur() throws Exception {
    // The original file has some superfluous sheets and the title row is not
    // in the first line so we downloaded and adapted it a bit to avoid to do this in software e.g.
    // as outlined in https://stackoverflow.com/questions/1834971/removing-a-row-from-an-excel-sheet-with-apache-poi-hssf
    // String url = "https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Energie/Unternehmen_Institutionen/HandelundVertrieb/Ladesaeulen/Ladesaeulenkarte_Datenbankauszug20.xlsx?__blob=publicationFile&v=2";
    File excelFile = new File(
        "src/test/data/Bundesnetzagentur/Ladesaeulenkarte_Datenbankauszug20.xlsx");
    ExcelSystem es = new ExcelSystem();
    es.connect();
    es.moveTo(excelFile.toURI().toString());
    long count = es.g().V().count().next().longValue();
    assertEquals(7733, count);
    if (debug)
      SimpleNode.dumpGraph(es.graph());
      //es.g().V().has("sheetname").out("rows").forEachRemaining(v -> {
      //  SimpleNode.printDebug.accept(v);
      // });
  }

}