├── Map-Matching TUM VMI
├── bin
│ ├── classes
│ │ └── .gitignore
│ ├── classes.dex
│ ├── resources.ap_
│ ├── Map-Matching TUM VMI.apk
│ ├── jarlist.cache
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ ├── marker_red.png
│ │ │ ├── ic_launcher.png
│ │ │ ├── marker_green.png
│ │ │ └── ic_action_search.png
│ │ ├── drawable-ldpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_action_search.png
│ │ └── drawable-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_action_search.png
│ └── AndroidManifest.xml
├── ic_launcher-web.png
├── res
│ ├── values
│ │ ├── styles.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── drawable-hdpi
│ │ ├── ic_launcher.png
│ │ ├── marker_red.png
│ │ ├── marker_green.png
│ │ └── ic_action_search.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_action_search.png
│ ├── values-v14
│ │ └── styles.xml
│ ├── drawable-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_action_search.png
│ ├── values-large
│ │ └── dimens.xml
│ ├── menu
│ │ ├── activity_main.xml
│ │ └── menu.xml
│ └── layout
│ │ ├── activity_main.xml
│ │ ├── settings.xml
│ │ └── psql_settings.xml
├── src
│ ├── classDiagramMM.png
│ ├── com
│ │ └── vmi
│ │ │ └── mapmatching_demo
│ │ │ ├── SQLConfiguration.java
│ │ │ ├── CandidateSegment.java
│ │ │ ├── SQLSettingsActivity.java
│ │ │ ├── GeneralSettingsActivity.java
│ │ │ ├── MyLocationListener.java
│ │ │ ├── CandidateNode.java
│ │ │ ├── FetchSQL.java
│ │ │ ├── STMatching.java
│ │ │ └── OverlayMapViewer.java
│ └── classDiagramMM.ucls
├── libs
│ ├── android-support-v4.jar
│ ├── gt-opengis-8.0-RC2.jar
│ ├── mapsforge-map-0.3.0.jar
│ ├── simplelatlng-1.0.1.jar
│ ├── gt-referencing-8.0-RC2.jar
│ ├── postgresql-9.1-902.jdbc4.jar
│ └── mapsforge-map-reader-0.3.0.jar
├── lint.xml
├── gen
│ └── com
│ │ └── vmi
│ │ └── mapmatching_demo
│ │ ├── BuildConfig.java
│ │ └── R.java
├── .classpath
├── project.properties
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── proguard-project.txt
├── .project
├── AndroidManifest.xml
├── GpsiesTrack (4).gpx
├── Munich Track.gpx
└── GpsiesTrack (8).gpx
└── README.md
/Map-Matching TUM VMI/bin/classes/.gitignore:
--------------------------------------------------------------------------------
1 | /classDiagramMM.png
2 | /classDiagramMM.ucls
3 | /com
4 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/classes.dex
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/resources.ap_
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/ic_launcher-web.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/classDiagramMM.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/src/classDiagramMM.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/Map-Matching TUM VMI.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/Map-Matching TUM VMI.apk
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/gt-opengis-8.0-RC2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/gt-opengis-8.0-RC2.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/mapsforge-map-0.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/mapsforge-map-0.3.0.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/simplelatlng-1.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/simplelatlng-1.0.1.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/gt-referencing-8.0-RC2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/gt-referencing-8.0-RC2.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependecy. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/postgresql-9.1-902.jdbc4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/postgresql-9.1-902.jdbc4.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-hdpi/marker_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-hdpi/marker_red.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-hdpi/marker_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-hdpi/marker_red.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/libs/mapsforge-map-reader-0.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/libs/mapsforge-map-reader-0.3.0.jar
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-hdpi/marker_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-hdpi/marker_green.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-hdpi/marker_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-hdpi/marker_green.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ermin-sakic/tum-map-matching/HEAD/Map-Matching TUM VMI/bin/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8dp
4 | 8dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values-large/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/gen/com/vmi/mapmatching_demo/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.vmi.mapmatching_demo;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Map-Matching Demo
4 | Settings
5 | MM-VMI
6 |
7 |
8 | - Mapnik
9 | - Opencyclemap
10 | - Database
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-15
15 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.6
12 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/SQLConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | public class SQLConfiguration {
4 | String dbName, ipAddress, username, password;
5 |
6 | public SQLConfiguration(String dbname, String ipAddressConfig, String usernameConfig, String passwordConfig){
7 | dbName = dbname;
8 | ipAddress = ipAddressConfig;
9 | username = usernameConfig;
10 | password = passwordConfig;
11 | }
12 |
13 | public String getDBName(){
14 | return dbName;
15 | }
16 | public String getIPAddress(){
17 | return ipAddress;
18 | }
19 | public String getUsername(){
20 | return username;
21 | }
22 | public String getPassword(){
23 | return password;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/CandidateSegment.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | public class CandidateSegment {
4 |
5 | CandidateNode StartNode, EndNode;
6 | boolean IsOneWay = false;
7 |
8 | public CandidateSegment(CandidateNode StartNode, CandidateNode EndNode, String isOneWay){
9 | this.StartNode=StartNode;
10 | this.EndNode=EndNode;
11 | if(isOneWay.equals("yes"))
12 | this.IsOneWay=true;
13 | }
14 |
15 | public CandidateNode getStartNode(){
16 | return StartNode;
17 | }
18 |
19 | public CandidateNode getEndNode(){
20 | return EndNode;
21 | }
22 |
23 | public boolean isOneWay(){
24 | return IsOneWay;
25 | }
26 |
27 | public boolean equals(CandidateSegment AnotherSegment){
28 | if(this.StartNode.equals(AnotherSegment.getStartNode())){
29 | if(this.EndNode.equals(AnotherSegment.getEndNode())){
30 | return true;
31 | }
32 | }
33 | return false;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Map-Matching TUM VMI
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
13 |
14 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
34 |
35 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
34 |
35 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ST-Matching algorithm for Android Applications (a map-matching project)
2 | ================
3 | Please feel free to read upon the documentation describing the work here:
4 | https://vmi.lmt.ei.tum.de/publications/students/Sakic-Bachelorarbeit.pdf
5 |
6 | In this thesis, an overview of modern map-matching algorithms, used to reconcile a positional
7 | observation onto the road using geometric, topological, statistical and advanced techniques in real-
8 | time, has been given. The usual methods of positioning, as well as the sources of errors associated
9 | to these methods have been discussed and the motivation for the process of matching presented.
10 | Furthermore, a scoring-based map-matching algorithm, called ST-Matching, which takes into
11 | account spatial, topological and temporal information of the setting, has been implemented for
12 | the mobile platform Android. The original workflow of the algorithm was additionally optimized
13 | and offers a robust detection of input "spikes" and erroneous observations when confronted with
14 | lower moving speed of the vehicle. For the use case on mobile phones, in addition to the GPS, it has
15 | been extended to also use Wi-Fi and Cell ID signals for positioning purposes. The implementation
16 | of this incremental algorithm has been tested and evaluated against multiple road tracks, in
17 | a dense urban area, and has resulted in a high percentage of correct matches. Although the
18 | algorithm matched the majority of observations correctly, in order to estimate the probability of
19 | correct matches, a performance comparison against other up-to-date map-matching algorithms is
20 | proposed. Furthermore, additional attention should be given to matching at intersections and an
21 | execution of multiple real-world tests considered in order to make the algorithm fully usable in
22 | practice.
23 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/layout/settings.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
22 |
23 |
28 |
29 |
35 |
36 |
37 |
42 |
43 |
49 |
50 |
51 |
57 |
58 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/SQLSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.EditText;
8 |
9 | public class SQLSettingsActivity extends Activity {
10 |
11 | static SQLConfiguration newSQLConfiguration = null;
12 | static boolean settingsSet = false;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.psql_settings);
18 |
19 | final EditText editAddress = (EditText) findViewById(R.id.edit_address);
20 | final EditText editDatabaseName = (EditText) findViewById(R.id.edit_database_name);
21 | final EditText editPassword = (EditText) findViewById(R.id.edit_password);
22 | final EditText editUsername = (EditText) findViewById(R.id.edit_username);
23 |
24 | final Button ApplyNewSettingsButton = (Button) findViewById(R.id.apply_new_settings);
25 |
26 | ApplyNewSettingsButton.setOnClickListener(new View.OnClickListener() {
27 | public void onClick(View v) {
28 |
29 | String newAddress = editAddress.getText().toString();
30 | String newDBName = editDatabaseName.getText().toString();
31 | String newUsername = editUsername.getText().toString();
32 | String newPassword = editPassword.getText().toString();
33 |
34 | setNewSQLSettings(new SQLConfiguration(newDBName, newAddress, newUsername, newPassword));
35 | finish();
36 | }
37 | });
38 | }
39 |
40 | //sets the initial SQL configuration data (VMI-TUM server)
41 | public static void initSQLConfig(){
42 | String newAddress = "129.187.223.154";
43 | String newDBName = "4326gis";
44 | String newUsername = "ermin";
45 | String newPassword = "";
46 |
47 | setNewSQLSettings(new SQLConfiguration(newDBName, newAddress, newUsername, newPassword));
48 | }
49 |
50 | public static void setNewSQLSettings(SQLConfiguration settings){
51 | newSQLConfiguration = settings;
52 | settingsSet = true;
53 | }
54 |
55 | public static boolean areSettingsSet(){
56 | return settingsSet;
57 | }
58 |
59 | public static SQLConfiguration getSQLSettings(){
60 | return newSQLConfiguration;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/GeneralSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.AdapterView;
7 | import android.widget.AdapterView.OnItemSelectedListener;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.Spinner;
12 |
13 | public class GeneralSettingsActivity extends Activity implements OnItemSelectedListener {
14 |
15 | //A skeleton-class for additional settings (tileset, sample rate and range-query radius chooser)
16 | String DEBUG = "debug";
17 | Spinner spinner;
18 | EditText setNewSampleRateBox;
19 | EditText setRangeQueryRadiusBox;
20 | Button applyNewSettingsButton;
21 | String RangeValue = "250";
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.settings);
27 |
28 | //final EditText editAddress = (EditText) findViewById(R.id.edit_address);
29 | spinner = (Spinner) findViewById(R.id.tileset_spinner);
30 | ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
31 | R.array.tileset_array, android.R.layout.simple_spinner_item);
32 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
33 | spinner.setAdapter(adapter);
34 | spinner.setOnItemSelectedListener(this);
35 |
36 | setNewSampleRateBox = (EditText) findViewById(R.id.edit_sampling_rate);
37 |
38 | if(setRangeQueryRadiusBox==null)
39 | setRangeQueryRadiusBox = (EditText) findViewById(R.id.set_range_query_radius);
40 | setRangeQueryRadiusBox.setText(RangeValue);
41 |
42 | applyNewSettingsButton = (Button) findViewById(R.id.apply_general_settings);
43 |
44 | applyNewSettingsButton.setOnClickListener(new View.OnClickListener() {
45 | public void onClick(View v) {
46 | RangeValue = setRangeQueryRadiusBox.getText().toString();
47 | FetchSQL.setRangeQueryRadius(Integer.parseInt(RangeValue));
48 | finish();
49 | }
50 | });
51 |
52 | }
53 |
54 | public void onItemSelected(AdapterView> parent, View view,
55 | int pos, long id) {
56 | }
57 |
58 | public void onNothingSelected(AdapterView> parent) {
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/res/layout/psql_settings.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
44 |
45 |
51 |
52 |
53 |
58 |
59 |
66 |
67 |
68 |
74 |
75 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/gen/com/vmi/mapmatching_demo/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.vmi.mapmatching_demo;
9 |
10 | public final class R {
11 | public static final class array {
12 | public static final int tileset_array=0x7f060000;
13 | }
14 | public static final class attr {
15 | }
16 | public static final class dimen {
17 | public static final int padding_large=0x7f040002;
18 | public static final int padding_medium=0x7f040001;
19 | public static final int padding_small=0x7f040000;
20 | }
21 | public static final class drawable {
22 | public static final int ic_action_search=0x7f020000;
23 | public static final int ic_launcher=0x7f020001;
24 | public static final int marker_green=0x7f020002;
25 | public static final int marker_red=0x7f020003;
26 | }
27 | public static final class id {
28 | public static final int apply_general_settings=0x7f09000b;
29 | public static final int apply_new_settings=0x7f090007;
30 | public static final int clear_button_lines=0x7f090002;
31 | public static final int clear_button_points=0x7f090001;
32 | public static final int edit_address=0x7f090003;
33 | public static final int edit_database_name=0x7f090004;
34 | public static final int edit_password=0x7f090006;
35 | public static final int edit_sampling_rate=0x7f090009;
36 | public static final int edit_username=0x7f090005;
37 | public static final int menu_settings=0x7f09000c;
38 | public static final int placeholder1=0x7f09000e;
39 | public static final int publicTransportMapView=0x7f090000;
40 | public static final int quit=0x7f09000f;
41 | public static final int set_range_query_radius=0x7f09000a;
42 | public static final int settings=0x7f09000d;
43 | public static final int tileset_spinner=0x7f090008;
44 | }
45 | public static final class layout {
46 | public static final int activity_main=0x7f030000;
47 | public static final int psql_settings=0x7f030001;
48 | public static final int settings=0x7f030002;
49 | }
50 | public static final class menu {
51 | public static final int activity_main=0x7f080000;
52 | public static final int menu=0x7f080001;
53 | }
54 | public static final class string {
55 | public static final int app_name=0x7f050000;
56 | public static final int menu_settings=0x7f050001;
57 | public static final int title_activity_main=0x7f050002;
58 | }
59 | public static final class style {
60 | public static final int AppTheme=0x7f070000;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/MyLocationListener.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 |
4 | import org.mapsforge.android.maps.overlay.OverlayItem;
5 | import org.mapsforge.core.GeoPoint;
6 |
7 | import android.location.Location;
8 | import android.location.LocationListener;
9 | import android.os.Bundle;
10 | import android.util.Log;
11 |
12 | public class MyLocationListener implements LocationListener {
13 |
14 | private static String DEBUG = "debug";
15 | private static Location lastLocation = null;
16 |
17 | @Override
18 | public void onLocationChanged(Location location) {
19 | if(lastLocation == null || (lastLocation.distanceTo(location)>50)){
20 | double latitude, longitude, altitude;
21 | float speed, bearing, accuracy;
22 | String provider = null;
23 | boolean hasBearing, hasSpeed, hasAccuracy, hasAltitude;
24 |
25 | OverlayMapViewer.counter++;
26 |
27 | latitude = location.getLatitude();
28 | longitude = location.getLongitude();
29 | provider = location.getProvider();
30 |
31 | hasBearing = location.hasBearing();
32 | hasSpeed = location.hasSpeed();
33 | hasAccuracy = location.hasAccuracy();
34 | hasAltitude = location.hasAltitude();
35 |
36 | String messageOnFix = "The " + provider + " Fix No.: " + OverlayMapViewer.counter + "\n" + "Latitude: " + latitude + "\nLongitude: " +
37 | longitude;
38 |
39 | if(hasBearing){
40 | bearing = location.getBearing();
41 | messageOnFix = messageOnFix + "\nBearing = " + bearing;
42 | }
43 | if(hasSpeed){
44 | speed = location.getSpeed();
45 | messageOnFix = messageOnFix + "\nSpeed = " + speed;
46 | }
47 | if(hasAccuracy){
48 | accuracy = location.getAccuracy();
49 | messageOnFix = messageOnFix + "\nAccuracy = " + accuracy;
50 | }
51 | if(hasAltitude){
52 | altitude = location.getAltitude();
53 | messageOnFix = messageOnFix + "\nAltitude = " + altitude;
54 | }
55 |
56 | Log.d(DEBUG, "Got a new location.");
57 |
58 | GeoPoint newGeoPoint = new GeoPoint(latitude, longitude);
59 | OverlayItem newLocation = new OverlayItem(newGeoPoint, "Unmapped fix No." + OverlayMapViewer.counter, messageOnFix);
60 |
61 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
62 | ;}
63 | OverlayMapViewer.addToItemizedOverlay(newLocation);
64 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
65 | ;}
66 |
67 | OverlayMapViewer.myMapController.setCenter(newGeoPoint);
68 |
69 | FetchSQL.setGpsFixData(location);
70 |
71 | lastLocation = location;
72 |
73 | //Execute the JBDC/SQL Query
74 | if(SQLSettingsActivity.areSettingsSet())
75 | new FetchSQL().execute();
76 | }
77 | }
78 |
79 | @Override
80 | public void onProviderDisabled(String provider) {
81 | // TODO Auto-generated method stub
82 | }
83 |
84 | @Override
85 | public void onProviderEnabled(String provider) {
86 | // TODO Auto-generated method stub
87 |
88 | }
89 |
90 | @Override
91 | public void onStatusChanged(String provider, int status, Bundle extras) {
92 | Log.d(DEBUG, "Changed provider to: "+provider);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/CandidateNode.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | import java.util.ArrayList;
4 |
5 | import org.mapsforge.core.GeoPoint;
6 |
7 | import android.location.Location;
8 |
9 | public class CandidateNode {
10 |
11 | String streetName, wayID;
12 |
13 | double nodeLatitude, nodeLongitude;
14 | Location respondingGPSFix, nodeLocation;
15 |
16 | int maxSpeed;
17 |
18 | boolean startCandidate = false, endCandidate = false, connected = false, bestMatch = false;
19 |
20 | float distanceToRespondingGPSFix;
21 |
22 | double observationProbability, timestamp;
23 |
24 | //contains all candidate nodes responding to the previous GPS Fix, however, the actual transmission probability is computed only for the
25 | //most probable previous match
26 | ArrayList pastNodesList = new ArrayList();
27 | ArrayList transmissionProbabilities = new ArrayList();
28 |
29 | //The spatial analysis function results (in regard to one or more previously obtained candidate nodes) are saved here
30 | ArrayList spatialAnalysisFunctionResults = new ArrayList();
31 |
32 | ArrayList temporalAnalysisFunctionResults = new ArrayList();
33 |
34 | public CandidateNode(double latitude, double longitude, Location parentGPSFix, String name, String way, int maxSpeed, double parentGPSFixTimestamp){
35 |
36 | Location locationOfThePoint = new Location("");
37 | locationOfThePoint.setLatitude(latitude);
38 | locationOfThePoint.setLongitude(longitude);
39 |
40 | this.nodeLocation = locationOfThePoint;
41 | this.nodeLatitude = latitude;
42 | this.nodeLongitude = longitude;
43 | this.respondingGPSFix = parentGPSFix;
44 | this.streetName = name;
45 | this.wayID = way;
46 | this.distanceToRespondingGPSFix = respondingGPSFix.distanceTo(locationOfThePoint);
47 | this.maxSpeed = maxSpeed;
48 | this.timestamp = parentGPSFixTimestamp;
49 | }
50 |
51 | public boolean equals(CandidateNode NodeToCompare){
52 | if(this.nodeLatitude == NodeToCompare.getLatitude())
53 | {
54 | if(this.nodeLongitude == NodeToCompare.getLongitude())
55 | {
56 | if(this.respondingGPSFix.equals(NodeToCompare.respondingGPSFix))
57 | return true;
58 | }
59 | }
60 | return false;
61 | }
62 |
63 | public double getLatitude(){
64 | return this.nodeLatitude;
65 | }
66 |
67 | public double getLongitude(){
68 | return this.nodeLongitude;
69 | }
70 |
71 | public Location getParentFix(){
72 | return this.respondingGPSFix;
73 | }
74 |
75 | public String getStreetName(){
76 | return streetName;
77 | }
78 |
79 | public String getWayName(){
80 | return this.wayID;
81 | }
82 |
83 | public double getDistanceToGPSFix(){
84 | return this.distanceToRespondingGPSFix;
85 | }
86 |
87 | public void setStartOrEndNode(String input){
88 | if(input.equals("start"))
89 | startCandidate = true;
90 | else endCandidate = true;
91 | }
92 |
93 | public GeoPoint toGeopoint(){
94 | return new GeoPoint(this.nodeLatitude, this.nodeLongitude);
95 | }
96 |
97 | public void setObservationProbability(double probability){
98 | this.observationProbability = probability;
99 | }
100 |
101 | public double getObservationProbability(){
102 | return this.observationProbability;
103 | }
104 |
105 | public double getTimestamp(){
106 | return this.timestamp;
107 | }
108 |
109 | public int getMaxSpeed(){
110 | return this.maxSpeed;
111 | }
112 |
113 | public void setTransmissionProbability(CandidateNode pastCandidate, Double transmissionProbability){
114 | this.pastNodesList.add(pastCandidate);
115 | this.transmissionProbabilities.add(transmissionProbability);
116 | this.spatialAnalysisFunctionResults.add(transmissionProbability*observationProbability);
117 | }
118 |
119 | public void setTemporalAnalysisResults(Double temporalAnalysisResult){
120 | this.temporalAnalysisFunctionResults.add(temporalAnalysisResult);
121 | }
122 |
123 | public void setLocation(Location myLocation){
124 | this.nodeLocation = myLocation;
125 | }
126 |
127 | public Location getLocation(){
128 | return this.nodeLocation;
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/FetchSQL.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 | import java.sql.Connection;
3 | import java.sql.DriverManager;
4 | import java.sql.ResultSet;
5 | import java.sql.SQLException;
6 | import java.sql.Statement;
7 | import java.util.ArrayList;
8 | import java.util.Scanner;
9 |
10 | import org.mapsforge.core.GeoPoint;
11 |
12 | import com.javadocmd.simplelatlng.LatLng;
13 | import com.javadocmd.simplelatlng.util.LengthUnit;
14 | import com.javadocmd.simplelatlng.window.RectangularWindow;
15 |
16 | import android.location.Location;
17 | import android.os.AsyncTask;
18 | import android.util.Log;
19 |
20 | class FetchSQL extends AsyncTask {
21 | private static String DEBUG = null;
22 |
23 | static double rangeQueryRadius = 105;
24 |
25 | private static Location rawGPSFix;
26 | private static double rawGPSFixTimestamp;
27 |
28 | static ArrayList closeNodesList;
29 | static ArrayList relevantNodesList;
30 | public static double lonMin, lonMax, latMin, latMax;
31 |
32 | @Override
33 | protected String doInBackground(Void... params) {
34 | getCloseNodesAndSTMatch();
35 | return DEBUG;
36 | }
37 |
38 | public void getCloseNodesAndSTMatch(){
39 | ResultSet rsStartNodes = null;
40 |
41 | try {
42 | Class.forName("org.postgresql.Driver");
43 | } catch (ClassNotFoundException e) {
44 | e.printStackTrace();
45 | }
46 |
47 | //Establishes a connection the PSQL database
48 | String url = "jdbc:postgresql://" + SQLSettingsActivity.getSQLSettings().getIPAddress()+"/"+ SQLSettingsActivity.getSQLSettings().getDBName()+
49 | "?user="+ SQLSettingsActivity.getSQLSettings().getUsername()+"&password="+ SQLSettingsActivity.getSQLSettings().getPassword();
50 | Connection conn;
51 | try {
52 | DriverManager.setLoginTimeout(5);
53 | conn = DriverManager.getConnection(url);
54 | Statement stStartNodes = conn.createStatement();
55 |
56 | String sqlStartNodes;
57 |
58 | //Creates a rectangular window used for the range query (for selecting the candidate line strings and nodes)
59 | RectangularWindow rectangularWindow = new RectangularWindow(new LatLng(rawGPSFix.getLatitude()
60 | , rawGPSFix.getLongitude()), rangeQueryRadius, rangeQueryRadius, LengthUnit.METER);
61 | latMin = rectangularWindow.getMinLatitude();
62 | latMax = rectangularWindow.getMaxLatitude();
63 | lonMin = rectangularWindow.getLeftLongitude();
64 | lonMax = rectangularWindow.getRightLongitude();
65 |
66 | //The SQL Query
67 | sqlStartNodes = "SELECT ST_NPoints(st_segmentize(way,0.0001)), name, way, st_x(ST_PointN(st_segmentize(way,0.0001),generate_series(1, ST_NPoints(st_segmentize(way,0.0001))))), " +
68 | "st_y(ST_PointN(st_segmentize(way,0.0001),generate_series(1, ST_NPoints(st_segmentize(way,0.0001))))),"
69 | + "oneway from planet_osm_line where ((st_x(st_startpoint(way)) between "+ lonMin + " and " +
70 | lonMax + " and st_y(st_startpoint(way)) between " + latMin + " and " + latMax + ") or ((st_x(ST_Line_Interpolate_Point(way, 0.5)) between "+
71 | lonMin + " and " + lonMax + ") and (st_y(ST_Line_Interpolate_Point(way, 0.5)) between " + (latMin) + " and " +
72 | latMax + ")) or ((st_x(ST_Line_Interpolate_Point(way, 0.25)) between "+
73 | lonMin + " and " + lonMax + ") and (st_y(ST_Line_Interpolate_Point(way, 0.25)) between " + (latMin) + " and " +
74 | latMax + ")) or ((st_x(ST_Line_Interpolate_Point(way, 0.75)) between "+
75 | lonMin + " and " + lonMax + ") and (st_y(ST_Line_Interpolate_Point(way, 0.75)) between " + (latMin) + " and " +
76 | latMax + ")) or ((st_x(ST_Line_Interpolate_Point(way, 0.85)) between "+
77 | lonMin + " and " + lonMax + ") and (st_y(ST_Line_Interpolate_Point(way, 0.85)) between " + (latMin) + " and " +
78 | latMax + ")) or ((st_x(ST_Line_Interpolate_Point(way, 0.15)) between "+
79 | lonMin + " and " + lonMax + ") and (st_y(ST_Line_Interpolate_Point(way, 0.15)) between " + (latMin) + " and " +
80 | latMax + ")) or (st_x(st_endpoint(way)) between " + lonMin + " and " + lonMax + " and " +
81 | "st_y(st_endpoint(way)) between " + latMin + " and " + latMax +
82 | ")) and highway!='footway' and (highway='tertiary'or highway='residential' or highway='traffic_signals' " +
83 | "or highway='service' or highway='secondary')"+";";
84 |
85 | //Log.d(DEBUG, "SQL StartNodes Command: " + sqlStartNodes);
86 |
87 | //Execution of the query and the ResultSet returned
88 | rsStartNodes = stStartNodes.executeQuery(sqlStartNodes);
89 |
90 | STMatching(rsStartNodes);
91 |
92 | rsStartNodes.close();
93 | stStartNodes.close();
94 |
95 | conn.close();
96 | } catch (SQLException e) {
97 | e.printStackTrace();
98 | }
99 | }
100 |
101 | public static void STMatching(ResultSet rsStartNodes){
102 | closeNodesList = new ArrayList();
103 | relevantNodesList = new ArrayList();
104 |
105 | try {
106 | while(rsStartNodes.next()) {
107 |
108 | String name = rsStartNodes.getString(2);
109 | String way = rsStartNodes.getString(3);
110 |
111 | //read out the StartNodes Latitudes and Longitudes from the ResultSet
112 | Double StartLongitude = Double.parseDouble(rsStartNodes.getString(4));
113 | Double StartLatitude = Double.parseDouble(rsStartNodes.getString(5));
114 |
115 | int maxSpeed = 0;
116 | /*try{
117 | if(!rsStartNodes.getString(7).isEmpty())
118 | maxSpeed = rsStartNodes.getInt(7);
119 | }
120 | catch(NullPointerException e){
121 | }*/
122 |
123 | CandidateNode newStartCandidate= new CandidateNode(StartLatitude, StartLongitude, rawGPSFix, name, way, maxSpeed, rawGPSFixTimestamp);
124 |
125 | if(StartLongitude >(lonMin) && StartLongitude<(lonMax)&&
126 | StartLatitude>(latMin) && StartLatitude<(latMax)){
127 | closeNodesList.add(newStartCandidate);
128 | }
129 | }
130 | } catch (NumberFormatException e1) {
131 | e1.printStackTrace();
132 | } catch (SQLException e1) {
133 | e1.printStackTrace();
134 | }
135 |
136 | //Log.d(DEBUG, "Road nodes: " + new Integer(roadNodesList.size()).toString());
137 | //Log.d(DEBUG, "Close nodes: " + new Integer(closeNodesList.size()).toString());
138 |
139 | for(CandidateNode e:closeNodesList){
140 | boolean doNotAdd = false;
141 | for(int i=0; i< closeNodesList.size(); i++){
142 | if(e.getWayName().equals(closeNodesList.get(i).getWayName()) && e.getDistanceToGPSFix()>closeNodesList.get(i).getDistanceToGPSFix()){
143 | doNotAdd = true;
144 | break;
145 | }
146 | }
147 |
148 | if(!doNotAdd){
149 | relevantNodesList.add(e);
150 | //Log.d(DEBUG, "New close point: Distance: "+ e.distanceToPoint + " Latitude "+e.getLatitude() + " Longitude " +
151 | // e.getLongitude() + " Street " + e.getStreetName() + " Way hash: " + e.getWayName().hashCode());
152 | }
153 | }
154 |
155 | if(relevantNodesList.size()>0){
156 | STMatching.updateRelevantNodesList(relevantNodesList);
157 | STMatching.assignObservationProbability();
158 | STMatching.assignTransmissionProbability();
159 | }
160 | //OverlayMapViewer.setCandidatePoints(closeNodesList);
161 | }
162 |
163 | @Override
164 | protected void onPostExecute(String value) {
165 | }
166 |
167 | public static void setGpsFixData(Location newFix){
168 | rawGPSFix = newFix;
169 | rawGPSFixTimestamp = ((double)newFix.getTime())/1000;
170 |
171 | //if(newFix.hasAccuracy())
172 | // rangeQueryRadius = 1.5*newFix.getAccuracy();
173 | }
174 |
175 | public static void setRangeQueryRadius(int rangeRadius){
176 | rangeQueryRadius = rangeRadius;
177 | }
178 |
179 | public ArrayList returnNodesList(String parameter){
180 | if(parameter.equals("close"))
181 | return closeNodesList;
182 | else return relevantNodesList;
183 | }
184 | }
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/GpsiesTrack (4).gpx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GpsiesTrack
5 |
6 | GpsiesTrack on GPSies.com
7 |
8 |
9 |
10 |
11 | GpsiesTrack on GPSies.com
12 |
13 |
14 | 526.00000
15 |
16 |
17 |
18 | 528.00000
19 |
20 |
21 |
22 | 528.00000
23 |
24 |
25 |
26 | 528.00000
27 |
28 |
29 |
30 | 526.00000
31 |
32 |
33 |
34 | 525.00000
35 |
36 |
37 |
38 | 525.00000
39 |
40 |
41 |
42 | 525.00000
43 |
44 |
45 |
46 | 524.00000
47 |
48 |
49 |
50 | 524.00000
51 |
52 |
53 |
54 | 524.00000
55 |
56 |
57 |
58 | 523.00000
59 |
60 |
61 |
62 | 522.00000
63 |
64 |
65 |
66 | 521.00000
67 |
68 |
69 |
70 | 524.00000
71 |
72 |
73 |
74 | 524.00000
75 |
76 |
77 |
78 | 524.00000
79 |
80 |
81 |
82 | 523.00000
83 |
84 |
85 |
86 | 523.00000
87 |
88 |
89 |
90 | 523.00000
91 |
92 |
93 |
94 | 522.00000
95 |
96 |
97 |
98 | 522.00000
99 |
100 |
101 |
102 | 523.00000
103 |
104 |
105 |
106 | 524.00000
107 |
108 |
109 |
110 | 523.00000
111 |
112 |
113 |
114 | 522.00000
115 |
116 |
117 |
118 | 520.00000
119 |
120 |
121 |
122 | 521.00000
123 |
124 |
125 |
126 | 522.00000
127 |
128 |
129 |
130 | 523.00000
131 |
132 |
133 |
134 | 523.00000
135 |
136 |
137 |
138 | 524.00000
139 |
140 |
141 |
142 | 522.00000
143 |
144 |
145 |
146 | 522.00000
147 |
148 |
149 |
150 | 522.00000
151 |
152 |
153 |
154 | 522.00000
155 |
156 |
157 |
158 | 524.00000
159 |
160 |
161 |
162 | 524.00000
163 |
164 |
165 |
166 | 523.00000
167 |
168 |
169 |
170 | 524.00000
171 |
172 |
173 |
174 | 524.00000
175 |
176 |
177 |
178 | 525.00000
179 |
180 |
181 |
182 | 525.00000
183 |
184 |
185 |
186 | 527.00000
187 |
188 |
189 |
190 | 527.00000
191 |
192 |
193 |
194 | 526.00000
195 |
196 |
197 |
198 | 525.00000
199 |
200 |
201 |
202 | 527.00000
203 |
204 |
205 |
206 | 528.00000
207 |
208 |
209 |
210 |
211 |
212 |
213 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/classDiagramMM.ucls:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/Munich Track.gpx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GpsiesTrack
5 |
6 | GpsiesTrack on GPSies.com
7 |
8 |
9 |
10 |
11 | GpsiesTrack on GPSies.com
12 |
13 |
14 | 529.00000
15 |
16 |
17 |
18 | 526.00000
19 |
20 |
21 |
22 | 526.00000
23 |
24 |
25 |
26 | 525.00000
27 |
28 |
29 |
30 | 525.00000
31 |
32 |
33 |
34 | 524.00000
35 |
36 |
37 |
38 | 523.00000
39 |
40 |
41 |
42 | 520.00000
43 |
44 |
45 |
46 | 520.00000
47 |
48 |
49 |
50 | 520.00000
51 |
52 |
53 |
54 | 520.00000
55 |
56 |
57 |
58 | 519.00000
59 |
60 |
61 |
62 | 519.00000
63 |
64 |
65 |
66 | 519.00000
67 |
68 |
69 |
70 | 519.00000
71 |
72 |
73 |
74 | 519.00000
75 |
76 |
77 |
78 | 520.00000
79 |
80 |
81 |
82 | 520.00000
83 |
84 |
85 |
86 | 521.00000
87 |
88 |
89 |
90 | 521.00000
91 |
92 |
93 |
94 | 520.00000
95 |
96 |
97 |
98 | 523.00000
99 |
100 |
101 |
102 | 521.00000
103 |
104 |
105 |
106 | 519.00000
107 |
108 |
109 |
110 | 518.00000
111 |
112 |
113 |
114 | 518.00000
115 |
116 |
117 |
118 | 517.00000
119 |
120 |
121 |
122 | 516.00000
123 |
124 |
125 |
126 | 516.00000
127 |
128 |
129 |
130 | 515.00000
131 |
132 |
133 |
134 | 516.00000
135 |
136 |
137 |
138 | 517.00000
139 |
140 |
141 |
142 | 517.00000
143 |
144 |
145 |
146 | 519.00000
147 |
148 |
149 |
150 | 519.00000
151 |
152 |
153 |
154 | 519.00000
155 |
156 |
157 |
158 | 517.00000
159 |
160 |
161 |
162 | 518.00000
163 |
164 |
165 |
166 | 518.00000
167 |
168 |
169 |
170 | 518.00000
171 |
172 |
173 |
174 | 518.00000
175 |
176 |
177 |
178 | 519.00000
179 |
180 |
181 |
182 | 518.00000
183 |
184 |
185 |
186 | 519.00000
187 |
188 |
189 |
190 | 519.00000
191 |
192 |
193 |
194 | 519.00000
195 |
196 |
197 |
198 | 519.00000
199 |
200 |
201 |
202 | 519.00000
203 |
204 |
205 |
206 | 518.00000
207 |
208 |
209 |
210 | 519.00000
211 |
212 |
213 |
214 | 520.00000
215 |
216 |
217 |
218 | 522.00000
219 |
220 |
221 |
222 | 523.00000
223 |
224 |
225 |
226 | 523.00000
227 |
228 |
229 |
230 | 525.00000
231 |
232 |
233 |
234 | 527.00000
235 |
236 |
237 |
238 |
239 |
240 |
241 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/GpsiesTrack (8).gpx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GpsiesTrack
5 |
6 | GpsiesTrack on GPSies.com
7 |
8 |
9 |
10 |
11 | GpsiesTrack on GPSies.com
12 |
13 |
14 | 529.00000
15 |
16 |
17 |
18 | 526.00000
19 |
20 |
21 |
22 | 526.00000
23 |
24 |
25 |
26 | 525.00000
27 |
28 |
29 |
30 | 525.00000
31 |
32 |
33 |
34 | 524.00000
35 |
36 |
37 |
38 | 523.00000
39 |
40 |
41 |
42 | 520.00000
43 |
44 |
45 |
46 | 520.00000
47 |
48 |
49 |
50 | 520.00000
51 |
52 |
53 |
54 | 520.00000
55 |
56 |
57 |
58 | 519.00000
59 |
60 |
61 |
62 | 519.00000
63 |
64 |
65 |
66 | 519.00000
67 |
68 |
69 |
70 | 519.00000
71 |
72 |
73 |
74 | 519.00000
75 |
76 |
77 |
78 | 520.00000
79 |
80 |
81 |
82 | 520.00000
83 |
84 |
85 |
86 | 520.00000
87 |
88 |
89 |
90 | 520.00000
91 |
92 |
93 |
94 | 520.00000
95 |
96 |
97 |
98 | 521.00000
99 |
100 |
101 |
102 | 520.00000
103 |
104 |
105 |
106 | 519.00000
107 |
108 |
109 |
110 | 518.00000
111 |
112 |
113 |
114 | 519.00000
115 |
116 |
117 |
118 | 518.00000
119 |
120 |
121 |
122 | 517.00000
123 |
124 |
125 |
126 | 516.00000
127 |
128 |
129 |
130 | 516.00000
131 |
132 |
133 |
134 | 515.00000
135 |
136 |
137 |
138 | 516.00000
139 |
140 |
141 |
142 | 516.00000
143 |
144 |
145 |
146 | 517.00000
147 |
148 |
149 |
150 | 519.00000
151 |
152 |
153 |
154 | 519.00000
155 |
156 |
157 |
158 | 519.00000
159 |
160 |
161 |
162 | 517.00000
163 |
164 |
165 |
166 | 518.00000
167 |
168 |
169 |
170 | 518.00000
171 |
172 |
173 |
174 | 518.00000
175 |
176 |
177 |
178 | 518.00000
179 |
180 |
181 |
182 | 519.00000
183 |
184 |
185 |
186 | 518.00000
187 |
188 |
189 |
190 | 519.00000
191 |
192 |
193 |
194 | 519.00000
195 |
196 |
197 |
198 | 519.00000
199 |
200 |
201 |
202 | 517.00000
203 |
204 |
205 |
206 | 518.00000
207 |
208 |
209 |
210 | 519.00000
211 |
212 |
213 |
214 | 518.00000
215 |
216 |
217 |
218 | 519.00000
219 |
220 |
221 |
222 | 520.00000
223 |
224 |
225 |
226 | 522.00000
227 |
228 |
229 |
230 | 523.00000
231 |
232 |
233 |
234 | 523.00000
235 |
236 |
237 |
238 | 525.00000
239 |
240 |
241 |
242 | 527.00000
243 |
244 |
245 |
246 |
247 |
248 |
249 |
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/STMatching.java:
--------------------------------------------------------------------------------
1 | package com.vmi.mapmatching_demo;
2 |
3 | import java.util.ArrayList;
4 |
5 | import android.graphics.Color;
6 | import android.location.Location;
7 | import android.util.Log;
8 |
9 | public class STMatching {
10 |
11 | static ArrayList relevantNodesList;
12 | static ArrayList> previousNodesList = new ArrayList>();
13 | static double lastBearing = 0, newBearing = 0, outlierBearing = 0, bearingDifference = 0;
14 | static boolean outlierDetected = false;
15 | static Boolean initPoint = true;
16 |
17 | //Mean and standard deviation in meters
18 | static double mu = 5;
19 | static double sigma = 10;
20 | static String DEBUG = "Bearing";
21 |
22 | //Likelihood that the raw fix should be mapped to the candidate in question, without considering the neighboring points
23 | public static void assignObservationProbability(){
24 | for(CandidateNode e:relevantNodesList){
25 | double probability = (1/(Math.sqrt(6.28)*sigma)) * Math.exp (-((Math.pow((e.getDistanceToGPSFix()-mu), 2))/(2*Math.pow(sigma,2))));
26 | e.setObservationProbability(probability);
27 | }
28 |
29 | CandidateNode observationBestMatch = null, observationSecondBestMatch;
30 |
31 | observationBestMatch = relevantNodesList.get(0);
32 | observationSecondBestMatch = relevantNodesList.get(0);
33 |
34 | for(CandidateNode e:relevantNodesList){
35 | if(e.getObservationProbability()>observationBestMatch.getObservationProbability()){
36 | observationSecondBestMatch = observationBestMatch;
37 | observationBestMatch = e;
38 | }
39 | else if(!e.equals(observationBestMatch) && (observationBestMatch.equals(observationSecondBestMatch) || e.getObservationProbability()>observationSecondBestMatch.getObservationProbability()))
40 | observationSecondBestMatch = e;
41 | }
42 |
43 | pointWeighting(observationBestMatch, observationSecondBestMatch);
44 |
45 | previousNodesList.add(relevantNodesList);
46 | }
47 |
48 | public static void assignTransmissionProbability(){
49 | if(previousNodesList.size()>1){
50 | //For all the candidate nodes from the previous fix compute the likelihood that the
51 | //“true” path from GPS_FIX_i-1 to GPS_FIX_i follows the shortest path from candidate node e to candidate node f
52 | double highestSpatialResult = 0;
53 | CandidateNode highestSpatialNode = null;
54 | int highestSpatialIndex = 0;
55 |
56 | for(CandidateNode f:previousNodesList.get(previousNodesList.size()-1)){
57 | for(CandidateNode e:previousNodesList.get(previousNodesList.size()-2)){
58 | //Compute the transmission probability only for the edges connecting the previous correct match and
59 | //the new candidates for current observation
60 | if(e.bestMatch == true){
61 | //Distance between the GPS fixes
62 | double distanceBetweenRawPoints = e.getParentFix().distanceTo(f.getParentFix());
63 |
64 | Location locationOfThePreviousPoint = new Location("");
65 | locationOfThePreviousPoint.setLatitude(e.getLatitude());
66 | locationOfThePreviousPoint.setLongitude(e.getLongitude());
67 |
68 | Location locationOfTheNextPoint = new Location("");
69 | locationOfTheNextPoint.setLatitude(f.getLatitude());
70 | locationOfTheNextPoint.setLongitude(f.getLongitude());
71 |
72 | //Distance and approximate speed between the two candidate nodes
73 | double distanceBetweenTheCandidateNodes = locationOfThePreviousPoint.distanceTo(locationOfTheNextPoint);
74 | double meanSpeed = distanceBetweenTheCandidateNodes/(f.getTimestamp()-e.getTimestamp());
75 |
76 | //Computing transmission probability
77 | double transmissionProbability = (distanceBetweenRawPoints/distanceBetweenTheCandidateNodes);
78 | f.setTransmissionProbability(e, transmissionProbability);
79 |
80 | //Always equals 1 because we're moving on one segment max, between the measurements - TO IMPLEMENT moving on multiple segments (sums, etc.)
81 | double temporalAnalysisFunctionResult = (f.getMaxSpeed()*meanSpeed)/(f.getMaxSpeed()*meanSpeed);
82 | f.setTemporalAnalysisResults(temporalAnalysisFunctionResult);
83 | }
84 | }
85 |
86 | //Determine the candidate node with the overall highest spatial/temporal function score
87 | for(Double e:f.spatialAnalysisFunctionResults){
88 | if(e>highestSpatialResult){
89 | highestSpatialResult = e;
90 | highestSpatialNode = f;
91 | highestSpatialIndex = f.spatialAnalysisFunctionResults.indexOf(e);
92 | }
93 | }
94 | }
95 |
96 | //Eventually, consider this node the best possible match for the current observation, and use to connect
97 | //to it during the succeding observation matching process, also draw it on the map.
98 | highestSpatialNode.bestMatch = true;
99 | previousNodesList.get(previousNodesList.size()-1).add(highestSpatialNode);
100 | OverlayMapViewer.setCandidatePoint(highestSpatialNode);
101 |
102 | //Build the GPS trajectory
103 | OverlayMapViewer.buildWaySegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex).getParentFix(), highestSpatialNode.getParentFix(), Color.RED);
104 |
105 | //Build the first edge after the second matching process, compute the initial bearing
106 | if(initPoint){
107 | OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
108 | lastBearing = highestSpatialNode.pastNodesList.get(highestSpatialIndex).getLocation().bearingTo(highestSpatialNode.getLocation());
109 | newBearing = lastBearing;
110 | Log.d(DEBUG, "Bearing: Initial point");
111 | }
112 |
113 | Log.d(DEBUG, "Last bearing: " + lastBearing);
114 |
115 | //Compute the succeeding bearing...
116 | if(!initPoint){
117 | if(!((highestSpatialNode.pastNodesList.get(highestSpatialIndex).getLatitude()==highestSpatialNode.getLatitude())
118 | && (highestSpatialNode.pastNodesList.get(highestSpatialIndex).getLatitude()==highestSpatialNode.getLatitude())))
119 | newBearing = highestSpatialNode.pastNodesList.get(highestSpatialIndex).getLocation().bearingTo(highestSpatialNode.getLocation());
120 | else newBearing = lastBearing;
121 | Log.d(DEBUG, "New Bearing:" + newBearing);
122 | }
123 |
124 | //, absolute value of the difference between the bearings...
125 | bearingDifference = Math.abs(Math.abs(newBearing) - Math.abs(lastBearing));
126 | if(outlierDetected == false)
127 | Log.d(DEBUG, " Bearing difference: " + bearingDifference);
128 |
129 | initPoint = false;
130 |
131 | //... and check for the outliers.
132 | if(!initPoint){
133 | if(bearingDifference<35 && outlierDetected==false){
134 | lastBearing = newBearing;
135 | OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
136 | }
137 | else if(outlierDetected==true){
138 | //OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
139 | //lastBearing = newBearing;
140 | Log.d(DEBUG, "Newest bearing: " + newBearing);
141 | Log.d(DEBUG, "The passed outlier candidate bearing: " + outlierBearing);
142 |
143 | bearingDifference = Math.abs(Math.abs(newBearing) - Math.abs(outlierBearing));
144 | if(bearingDifference<35){
145 | //asumption that the candidate node was an outlier proven FALSE
146 | lastBearing = newBearing;
147 | OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
148 | outlierDetected = false;
149 | }
150 | else{
151 | //asumption that the candidate node was an outlier proven TRUE - continue using the bearing from the correct
152 | //matches, 2 ticks before
153 | outlierDetected = false;
154 | //OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
155 | //initPoint = true
156 | }
157 | }
158 | else if(bearingDifference>35 && highestSpatialNode.pastNodesList.get(highestSpatialIndex).getWayName()!= highestSpatialNode.getWayName()){
159 | //OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.RED);
160 | //lastBearing = newBearing;
161 | outlierDetected = true;
162 | outlierBearing = highestSpatialNode.pastNodesList.get(highestSpatialIndex).getLocation().bearingTo(highestSpatialNode.getLocation());
163 | //OverlayMapViewer.buildRoadSegment(highestSpatialNode.pastNodesList.get(highestSpatialIndex), highestSpatialNode, Color.BLUE);
164 | Log.d(DEBUG, "Bearing: Outlier detected! Outlier bearing: " + outlierBearing);
165 | }
166 | }
167 | }}
168 |
169 | public static void updateRelevantNodesList(ArrayList list){
170 | relevantNodesList = list;
171 | Log.d(DEBUG, "Candidate Nodes list size: " + relevantNodesList.size());
172 | }
173 |
174 | public static void assignObservationProbability(CandidateNode node){
175 | double probability = (1/(Math.sqrt(6.28)*sigma)) * Math.exp (-((Math.pow((node.getDistanceToGPSFix()-mu), 2))/(2*Math.pow(sigma,2))));
176 | node.setObservationProbability(probability);
177 | }
178 |
179 | public static void pointWeighting(CandidateNode observationBestMatch, CandidateNode observationSecondBestMatch){
180 | if(observationBestMatch.getWayName().equals(observationSecondBestMatch.getWayName()))
181 | {
182 | Location locationBestMatch = observationBestMatch.getLocation();
183 | Location locationSecondMatch = observationSecondBestMatch.getLocation();
184 |
185 | double distanceBetween = locationSecondMatch.distanceTo(locationBestMatch);
186 |
187 | double ratio = (observationSecondBestMatch.getObservationProbability()/observationBestMatch.getObservationProbability())/2.0;
188 | double theTrueDistance = distanceBetween*ratio;
189 |
190 | double dist = (theTrueDistance/1000.0)/6371.0;
191 | double lat1 = Math.toRadians(observationBestMatch.getLatitude());
192 | double lon1 = Math.toRadians(observationBestMatch.getLongitude());
193 | double bearing = Math.toRadians(locationBestMatch.bearingTo(locationSecondMatch));
194 |
195 | double lat2 = Math.asin( Math.sin(lat1)*Math.cos(dist) + Math.cos(lat1)*Math.sin(dist)*Math.cos(bearing) );
196 | double a = Math.atan2(Math.sin(bearing)*Math.sin(dist)*Math.cos(lat1), Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));
197 | System.out.println("a = " + a);
198 | double lon2 = lon1 + a;
199 |
200 | lon2 = (lon2+ 3*Math.PI) % (2*Math.PI) - Math.PI;
201 |
202 | Log.d(DEBUG, "Latitude = "+Math.toDegrees(lat2)+"\nLongitude = "+Math.toDegrees(lon2));
203 | double matchedLatitude = Math.toDegrees(lat2);
204 | double matchedLongitude = Math.toDegrees(lon2);
205 |
206 | CandidateNode geoMatchedCandidate= new CandidateNode(matchedLatitude, matchedLongitude,
207 | observationBestMatch.getParentFix(), observationBestMatch.getStreetName(),
208 | observationBestMatch.getWayName(), observationBestMatch.getMaxSpeed(), observationBestMatch.getTimestamp());
209 |
210 | assignObservationProbability(geoMatchedCandidate);
211 |
212 | if(previousNodesList.size()==0){
213 | geoMatchedCandidate.bestMatch = true;
214 | OverlayMapViewer.setCandidatePoint(geoMatchedCandidate);}
215 |
216 | relevantNodesList.add(geoMatchedCandidate);
217 | }
218 | else if(previousNodesList.size()==0){
219 | observationBestMatch.bestMatch = true;
220 | OverlayMapViewer.setCandidatePoint(observationBestMatch);
221 | }
222 | }
223 | }
--------------------------------------------------------------------------------
/Map-Matching TUM VMI/src/com/vmi/mapmatching_demo/OverlayMapViewer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, 2011, 2012 mapsforge.org
3 | *
4 | * This program is free software: you can redistribute it and/or modify it under the
5 | * terms of the GNU Lesser General Public License as published by the Free Software
6 | * Foundation, either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY
9 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU Lesser General Public License along with
13 | * this program. If not, see .
14 | */
15 | package com.vmi.mapmatching_demo;
16 |
17 | import org.mapsforge.android.maps.MapActivity;
18 | import org.mapsforge.android.maps.MapController;
19 | import org.mapsforge.android.maps.MapView;
20 | import org.mapsforge.android.maps.mapgenerator.MapGeneratorFactory;
21 | import org.mapsforge.android.maps.mapgenerator.MapGeneratorInternal;
22 | import org.mapsforge.android.maps.overlay.ArrayItemizedOverlay;
23 | import org.mapsforge.android.maps.overlay.ArrayWayOverlay;
24 | import org.mapsforge.android.maps.overlay.ItemizedOverlay;
25 | import org.mapsforge.android.maps.overlay.OverlayItem;
26 | import org.mapsforge.android.maps.overlay.OverlayWay;
27 | import org.mapsforge.core.GeoPoint;
28 |
29 | import java.util.ArrayList;
30 |
31 | import android.app.AlertDialog;
32 | import android.app.AlertDialog.Builder;
33 | import android.content.Context;
34 | import android.content.Intent;
35 | import android.graphics.Color;
36 | import android.graphics.Paint;
37 | import android.graphics.drawable.Drawable;
38 | import android.location.Criteria;
39 | import android.location.Location;
40 | import android.location.LocationManager;
41 | import android.os.Bundle;
42 | import android.util.Log;
43 | import android.view.Menu;
44 | import android.view.MenuInflater;
45 | import android.view.MenuItem;
46 | import android.view.View;
47 | import android.widget.Button;
48 | /**
49 | * Main View Class.
50 | */
51 | public class OverlayMapViewer extends MapActivity {
52 | public static MapController myMapController;
53 | private static MapView mapView;
54 | private static ArrayItemizedOverlay itemizedOverlay;
55 | private static Drawable itemCandidatesMarker;
56 | private static ArrayWayOverlay wayOverlay, wayOverlayRed, nodesOverlay;
57 |
58 | public static int counter = 0;
59 | public static int IS_THREAD_RUNNING = 0;
60 | private static int pollingTime = 5000;
61 | private static String DEBUG = "debug";
62 |
63 | MyLocationListener NewLocationListener;
64 |
65 | private static class MyItemizedOverlay extends ArrayItemizedOverlay {
66 | private final Context context;
67 |
68 | /**
69 | * Constructs a new MyItemizedOverlay.
70 | *
71 | * @param defaultMarker
72 | * the default marker (may be null).
73 | * @param context
74 | * the reference to the application context.
75 | */
76 | MyItemizedOverlay(Drawable defaultMarker, Context context) {
77 | super(defaultMarker);
78 | this.context = context;
79 | }
80 |
81 | /**
82 | * Handles a tap event on the given item.
83 | */
84 | @Override
85 | protected boolean onTap(int index) {
86 | OverlayItem item = createItem(index);
87 | if (item != null) {
88 | Builder builder = new AlertDialog.Builder(this.context);
89 | builder.setIcon(android.R.drawable.ic_menu_info_details);
90 | builder.setTitle(item.getTitle());
91 | builder.setMessage(item.getSnippet());
92 | builder.setPositiveButton("OK", null);
93 | builder.show();
94 | }
95 | return true;
96 | }
97 | }
98 |
99 | @Override
100 | protected void onCreate(Bundle savedInstanceState) {
101 | super.onCreate(savedInstanceState);
102 | setContentView(R.layout.activity_main);
103 |
104 | STMatching.initPoint = true;
105 |
106 | mapView = (MapView) findViewById(R.id.publicTransportMapView);
107 | mapView.setMapGenerator(MapGeneratorFactory.createMapGenerator(MapGeneratorInternal.MAPNIK));
108 | mapView.setClickable(true);
109 | mapView.setBuiltInZoomControls(true);
110 |
111 | myMapController = mapView.getController();
112 |
113 | // create the default marker for overlay items
114 | Drawable itemGPSMarker = getResources().getDrawable(R.drawable.marker_red);
115 |
116 | // create an individual marker for an overlay item
117 | itemCandidatesMarker = getResources().getDrawable(R.drawable.marker_green);
118 |
119 | // initialize the Paint objects
120 | initPaintObjects();
121 |
122 | // create the ItemizedOverlay and add the items
123 | if(itemizedOverlay==null)
124 | itemizedOverlay = new MyItemizedOverlay(itemGPSMarker, this);
125 |
126 | //initial connection to TUM-VMI Server
127 | SQLSettingsActivity.initSQLConfig();
128 |
129 | final LocationManager NetworkLocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
130 | NewLocationListener = new MyLocationListener();
131 | NetworkLocManager.requestLocationUpdates(NetworkLocManager.getBestProvider(createFineCriteria(), true)
132 | , pollingTime , 0, NewLocationListener);
133 |
134 |
135 | final Button clearPointsButton = (Button) findViewById(R.id.clear_button_points);
136 | final Button clearLinesButton = (Button) findViewById(R.id.clear_button_lines);
137 |
138 | clearPointsButton.setOnClickListener(new View.OnClickListener() {
139 | public void onClick(View v) {
140 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
141 | ;}
142 | itemizedOverlay.clear();
143 | }
144 | });
145 |
146 | clearLinesButton.setOnClickListener(new View.OnClickListener() {
147 | public void onClick(View v) {
148 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
149 | ;}
150 | wayOverlay.clear();
151 | wayOverlayRed.clear();
152 | }
153 | });
154 | }
155 |
156 |
157 | @Override
158 | public boolean onCreateOptionsMenu(Menu menu) {
159 | MenuInflater inflater = getMenuInflater();
160 | inflater.inflate(R.menu.menu, menu);
161 | return true;
162 | }
163 |
164 | @Override
165 | public boolean onOptionsItemSelected(MenuItem item) {
166 | switch (item.getItemId()) {
167 | case R.id.settings:
168 | Intent myIntent = new Intent(OverlayMapViewer.this, SQLSettingsActivity.class);
169 | OverlayMapViewer.this.startActivity(myIntent);
170 | break;
171 | case R.id.placeholder1:
172 | Intent myIntent2 = new Intent(OverlayMapViewer.this, GeneralSettingsActivity.class);
173 | OverlayMapViewer.this.startActivity(myIntent2);
174 | break;
175 | case R.id.quit: finish();
176 | break;
177 | }
178 | return true;
179 | }
180 |
181 | /** this criteria needs high accuracy, high power, and cost */
182 | public static Criteria createFineCriteria() {
183 |
184 | Criteria c = new Criteria();
185 | c.setAccuracy(Criteria.ACCURACY_FINE);
186 | c.setAltitudeRequired(false);
187 | c.setBearingRequired(false);
188 | c.setSpeedRequired(false);
189 | c.setCostAllowed(true);
190 | return c;
191 | }
192 |
193 | @Override
194 | protected void onPause()
195 | {
196 | super.onPause();
197 | }
198 |
199 | @Override
200 | protected void onResume()
201 | {
202 | super.onResume();
203 | }
204 |
205 | public static void addToItemizedOverlay(OverlayItem overlayItem){
206 | IS_THREAD_RUNNING = 1;
207 | itemizedOverlay.addItem(overlayItem);
208 | try{
209 | mapView.getOverlays().add(itemizedOverlay);}
210 | catch(IllegalThreadStateException e){
211 | }
212 | IS_THREAD_RUNNING = 0;
213 | }
214 |
215 | //Use to draw a list of candidate points - testing purposes
216 | /*
217 | public static void setCandidatePoints(ArrayList candidateNodeList){
218 | int CandidateCounter = 1;
219 | for (CandidateNode currentCandidateNode : candidateNodeList ){
220 | String messageOnShow = "Source: Fix No. " + counter + "\n" + "Latitude: " + currentCandidateNode.getLatitude() + "\nLongitude: " +
221 | currentCandidateNode.getLongitude() + "\n" + "Observation probability: " + currentCandidateNode.getObservationProbability();
222 | GeoPoint newCandidatePoint = new GeoPoint(currentCandidateNode.getLatitude(), currentCandidateNode.getLongitude());
223 |
224 | //addCandidateNodeLine(parentPoint, newCandidatePoint);
225 | OverlayItem newCandidatePointLocation = new OverlayItem(newCandidatePoint, "Candidate Point " + CandidateCounter, messageOnShow,
226 | ItemizedOverlay.boundCenterBottom(itemCandidatesMarker));
227 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
228 | ;}
229 | addToItemizedOverlay(newCandidatePointLocation);
230 | while(IS_THREAD_RUNNING==1){
231 | ;}
232 |
233 | CandidateCounter++;}
234 | }
235 | */
236 |
237 | public static void setCandidatePoint(CandidateNode currentCandidateNode){
238 | String messageOnShow = "Source: Fix No. " + counter + "\n" + "Latitude: " + currentCandidateNode.getLatitude() + "\nLongitude: " +
239 | currentCandidateNode.getLongitude() + "\n" + "Observation probability: " + currentCandidateNode.getObservationProbability();
240 | GeoPoint newCandidatePoint = new GeoPoint(currentCandidateNode.getLatitude(), currentCandidateNode.getLongitude());
241 |
242 | //addCandidateNodeLine(parentPoint, newCandidatePoint);
243 | OverlayItem newCandidatePointLocation = new OverlayItem(newCandidatePoint, "Matched Point", messageOnShow,
244 | ItemizedOverlay.boundCenterBottom(itemCandidatesMarker));
245 | while(OverlayMapViewer.IS_THREAD_RUNNING==1){
246 | ;}
247 | addToItemizedOverlay(newCandidatePointLocation);
248 | while(IS_THREAD_RUNNING==1){
249 | ;}
250 | }
251 |
252 | public static void initPaintObjects(){
253 | Paint wayDefaultPaintOutline, wayRedPaintOutline, wayDefaultPaintFill, wayRedPaintFill, nodesDefaultPaintFill, nodesDefaultPaintOutline;
254 |
255 | // create the default paint objects for overlay circles
256 | Paint circleDefaultPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
257 | circleDefaultPaintFill.setStyle(Paint.Style.FILL);
258 | circleDefaultPaintFill.setColor(Color.BLUE);
259 | circleDefaultPaintFill.setAlpha(64);
260 |
261 | Paint circleDefaultPaintOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
262 | circleDefaultPaintOutline.setStyle(Paint.Style.STROKE);
263 | circleDefaultPaintOutline.setColor(Color.BLUE);
264 | circleDefaultPaintOutline.setAlpha(128);
265 | circleDefaultPaintOutline.setStrokeWidth(3);
266 |
267 | // create an individual paint object for an overlay circle
268 | Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
269 | circlePaint.setStyle(Paint.Style.FILL);
270 | circlePaint.setColor(Color.MAGENTA);
271 | circlePaint.setAlpha(96);
272 |
273 | // create the default paint objects for overlay ways
274 | wayDefaultPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
275 | wayDefaultPaintFill.setStyle(Paint.Style.STROKE);
276 | wayDefaultPaintFill.setColor(Color.BLUE);
277 | wayDefaultPaintFill.setAlpha(160);
278 | wayDefaultPaintFill.setStrokeWidth(2);
279 | wayDefaultPaintFill.setStrokeJoin(Paint.Join.ROUND);
280 |
281 | wayDefaultPaintOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
282 | wayDefaultPaintOutline.setStyle(Paint.Style.STROKE);
283 | wayDefaultPaintOutline.setColor(Color.BLUE);
284 | wayDefaultPaintOutline.setAlpha(128);
285 | wayDefaultPaintOutline.setStrokeWidth(2);
286 | wayDefaultPaintOutline.setStrokeJoin(Paint.Join.ROUND);
287 |
288 | // create the default paint objects for overlay ways
289 | wayRedPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
290 | wayRedPaintFill.setStyle(Paint.Style.STROKE);
291 | wayRedPaintFill.setColor(Color.RED);
292 | wayRedPaintFill.setAlpha(160);
293 | wayRedPaintFill.setStrokeWidth(2);
294 | wayRedPaintFill.setStrokeJoin(Paint.Join.ROUND);
295 |
296 | wayRedPaintOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
297 | wayRedPaintOutline.setStyle(Paint.Style.STROKE);
298 | wayRedPaintOutline.setColor(Color.RED);
299 | wayRedPaintOutline.setAlpha(128);
300 | wayRedPaintOutline.setStrokeWidth(2);
301 | wayRedPaintOutline.setStrokeJoin(Paint.Join.ROUND);
302 |
303 | // create the default paint objects for overlay ways
304 | nodesDefaultPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
305 | nodesDefaultPaintFill.setStyle(Paint.Style.STROKE);
306 | nodesDefaultPaintFill.setColor(Color.RED);
307 | nodesDefaultPaintFill.setAlpha(160);
308 | nodesDefaultPaintFill.setStrokeWidth(1);
309 | nodesDefaultPaintFill.setStrokeJoin(Paint.Join.ROUND);
310 |
311 | nodesDefaultPaintOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
312 | nodesDefaultPaintOutline.setStyle(Paint.Style.STROKE);
313 | nodesDefaultPaintOutline.setColor(Color.RED);
314 | nodesDefaultPaintOutline.setAlpha(128);
315 | nodesDefaultPaintOutline.setStrokeWidth(1);
316 | nodesDefaultPaintOutline.setStrokeJoin(Paint.Join.ROUND);
317 |
318 | nodesOverlay = new ArrayWayOverlay(nodesDefaultPaintFill, nodesDefaultPaintOutline);
319 | wayOverlay = new ArrayWayOverlay(wayDefaultPaintFill, wayDefaultPaintOutline);
320 | wayOverlayRed = new ArrayWayOverlay(wayRedPaintFill, wayRedPaintOutline);
321 | }
322 |
323 | public static void addWayLine(GeoPoint geoPoint1, GeoPoint geoPoint2, int color){
324 | // create the WayOverlay and add the ways
325 | OverlayWay way1 = new OverlayWay(new GeoPoint[][] { { geoPoint1, geoPoint2 } });
326 |
327 | if(color == Color.BLUE){
328 | wayOverlay.addWay(way1);
329 | try{
330 | mapView.getOverlays().add(wayOverlay);}
331 | catch(IllegalThreadStateException e){
332 | }
333 | }
334 | else if(color == Color.RED){
335 | wayOverlayRed.addWay(way1);
336 | try{
337 | mapView.getOverlays().add(wayOverlayRed);}
338 | catch(IllegalThreadStateException e){
339 | }
340 | }
341 | }
342 |
343 | public static void buildRoadSegment(CandidateNode node1, CandidateNode node2, int color){
344 | addWayLine(node1.toGeopoint(), node2.toGeopoint(), color);
345 | }
346 |
347 | public static void buildWaySegment(Location node1, Location node2, int color){
348 | GeoPoint newCandidatePoint1 = new GeoPoint(node1.getLatitude(), node1.getLongitude());
349 | GeoPoint newCandidatePoint2 = new GeoPoint(node2.getLatitude(), node2.getLongitude());
350 |
351 | addWayLine(newCandidatePoint1, newCandidatePoint2, color);
352 | }
353 | }
354 |
355 |
--------------------------------------------------------------------------------