/MapMatching

App for Trajectories Map Matching

Primary LanguageJavaMIT LicenseMIT

Map Matching

ADICIONANDO A DEPENDÊNCIA:

To make a library available, a Jitpack platform will be used, which shares a more original version of the repository.

  • Add the repository in pom.xml:
<repositories>
  <repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
  </repository>
</repositories>
  • Add the dependency in pom.xml:
<dependency>
    <groupId>com.github.gabrielczar</groupId>
    <artifactId>MapMatching</artifactId>
    <version>1.3.0</version>
</dependency>

Using Docker Container Postgres

  • Create local to save postgres data

docker volume create pg_data

  • Create instance posgres with postgis extension
docker run --name=trajectory-data-postgis -d -e POSTGRES_USER=postgres -e POSTGRES_PASS=postgres -e POSTGRES_DBNAME=trajectory-data -e ALLOW_IP_RANGE=0.0.0.0/0 -p 5432:5432 -v pg_data:/var/lib/postgresql --restart=always kartoza/postgis:9.6-2.4

Extra Queries

Create table

  • Create table to save output
CREATE TABLE matched_points (
	id serial primary key,
	natural_id integer, 
 	datetime timestamp,
 	longitude double precision,
 	latitude double precision,
	edge_id bigint,
	offset double precision,
	geometry point
);
  • Create table with content
CREATE TABLE dataset (
 id serial primary key,  
 natural_id integer, 
 datetime timestamp,
 longitude double precision,
 latitude double precision
);

Aditional columns

  • Add column for geometry
ALTER TABLE dataset ADD COLUMN geom GEOMETRY;
  • Add aditional column for serial id in dataset
ALTER TABLE dataset ADD COLUMN ID SERIAL PRIMARY KEY;

Aditional update values

  • Create geometrys for each dataset location
update dataset
set geom = ST_SetSRID(ST_MakePoint(t.long, t.lat), 4326)
from (
       select id, longitude as long, 
         latitude as lat from dataset) as t
WHERE t.id = dataset.id;

Aditional queries

  • Search by date interval
SELECT * FROM dataset WHERE date_time::date >= date '2008-02-02' AND date_time::date < date '2008-02-03';