├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── barefoot-style.xml ├── config ├── oberbayern.properties ├── server.properties └── tracker.properties ├── deps ├── esri-geometry-api │ └── license.txt ├── geographiclib │ └── license.txt ├── hamcrest │ └── license.txt ├── jackson │ └── license.txt ├── java-json │ └── license.txt ├── jeromq │ └── license.txt ├── junit │ └── license.txt ├── logback │ └── license.txt ├── postgresql-jdbc │ └── license.txt └── slf4j │ └── license.txt ├── doc-files ├── build-pics.py ├── com │ └── bmwcarit │ │ └── barefoot │ │ ├── analysis │ │ ├── dbscan-satellite.png │ │ └── dbscan.geojson-io.json │ │ ├── barefoot-ecosystem.pdf │ │ ├── barefoot-ecosystem.png │ │ ├── barefoot-ecosystem.tex │ │ ├── barefoot-lib-dependencies.pdf │ │ ├── barefoot-lib-dependencies.png │ │ ├── barefoot-lib-dependencies.tex │ │ ├── barefoot-map-dependencies.pdf │ │ ├── barefoot-map-dependencies.png │ │ ├── barefoot-map-dependencies.tex │ │ ├── barefoot-util-dependencies.pdf │ │ ├── barefoot-util-dependencies.png │ │ ├── barefoot-util-dependencies.tex │ │ ├── markov │ │ ├── kstate-1.pdf │ │ ├── kstate-1.png │ │ ├── kstate-1.tex │ │ ├── kstate-2.pdf │ │ ├── kstate-2.png │ │ ├── kstate-2.tex │ │ ├── kstate-3.pdf │ │ ├── kstate-3.png │ │ ├── kstate-3.tex │ │ ├── kstate-4.pdf │ │ ├── kstate-4.png │ │ ├── kstate-4.tex │ │ ├── kstate-5.pdf │ │ ├── kstate-5.png │ │ ├── kstate-5.tex │ │ ├── kstate-6.pdf │ │ ├── kstate-6.png │ │ ├── kstate-6.tex │ │ ├── model.pdf │ │ ├── model.png │ │ └── model.tex │ │ ├── matcher │ │ ├── benchmark │ │ │ ├── benchmark.pdf │ │ │ └── benchmark.png │ │ ├── matcher-components.pdf │ │ ├── matcher-components.png │ │ ├── matcher-components.tex │ │ ├── matching-satellite.png │ │ └── matching.geojson-io.json │ │ ├── spatial │ │ ├── intercept-satellite.png │ │ ├── intercept.geojson-io.json │ │ ├── radius-satellite.png │ │ └── radius.geojson-io.json │ │ ├── topology │ │ ├── graph-route.pdf │ │ ├── graph-route.png │ │ ├── graph-route.tex │ │ ├── graph.pdf │ │ ├── graph.png │ │ └── graph.tex │ │ └── tracker │ │ ├── monitor-1152x864.gif │ │ ├── monitor-1600x1000.gif │ │ ├── tracker-monitor.pdf │ │ ├── tracker-monitor.png │ │ ├── tracker-monitor.tex │ │ ├── tracker-scalable.pdf │ │ ├── tracker-scalable.png │ │ └── tracker-scalable.tex └── style │ └── eclipse-java-style.xml ├── map ├── Dockerfile ├── osm │ ├── import.sh │ └── pgsnapshot_schema_0.6.sql ├── pgsql │ ├── pg_hba.conf.patch │ └── postgresql.conf.patch ├── samples │ ├── import.sh │ └── x0001-015.sql └── tools │ ├── bfmap.py │ ├── osm2ways.py │ ├── road-types.json │ ├── test │ ├── run.sh │ ├── test-types.json │ ├── test.properties │ ├── test_bfmap.py │ └── test_bfmap.sql │ ├── ways.py │ └── ways2bfmap.py ├── pom.xml ├── src ├── main │ ├── java │ │ └── com │ │ │ └── bmwcarit │ │ │ └── barefoot │ │ │ ├── analysis │ │ │ ├── DBCAN.java │ │ │ ├── DBRCAN.java │ │ │ ├── DBSCAN.java │ │ │ └── package-info.java │ │ │ ├── markov │ │ │ ├── Factory.java │ │ │ ├── Filter.java │ │ │ ├── KState.java │ │ │ ├── Sample.java │ │ │ ├── StateCandidate.java │ │ │ ├── StateMemory.java │ │ │ ├── StateTransition.java │ │ │ └── package-info.java │ │ │ ├── matcher │ │ │ ├── Benchmark.java │ │ │ ├── Matcher.java │ │ │ ├── MatcherCandidate.java │ │ │ ├── MatcherFactory.java │ │ │ ├── MatcherKState.java │ │ │ ├── MatcherSample.java │ │ │ ├── MatcherServer.java │ │ │ ├── MatcherTransition.java │ │ │ ├── Minset.java │ │ │ ├── ServerControl.java │ │ │ └── package-info.java │ │ │ ├── road │ │ │ ├── BaseRoad.java │ │ │ ├── BfmapReader.java │ │ │ ├── BfmapWriter.java │ │ │ ├── Heading.java │ │ │ ├── PostGISReader.java │ │ │ ├── RoadReader.java │ │ │ ├── RoadWriter.java │ │ │ └── package-info.java │ │ │ ├── roadmap │ │ │ ├── Distance.java │ │ │ ├── Loader.java │ │ │ ├── Road.java │ │ │ ├── RoadMap.java │ │ │ ├── RoadPoint.java │ │ │ ├── Route.java │ │ │ ├── Time.java │ │ │ ├── TimePriority.java │ │ │ └── package-info.java │ │ │ ├── scheduler │ │ │ ├── Group.java │ │ │ ├── Scheduler.java │ │ │ ├── StaticScheduler.java │ │ │ ├── Task.java │ │ │ └── Worker.java │ │ │ ├── spatial │ │ │ ├── Geography.java │ │ │ ├── Intercept.java │ │ │ ├── Intersect.java │ │ │ ├── QuadTreeIndex.java │ │ │ ├── SpatialIndex.java │ │ │ ├── SpatialOperator.java │ │ │ ├── Vector.java │ │ │ └── package-info.java │ │ │ ├── topology │ │ │ ├── AbstractEdge.java │ │ │ ├── Cost.java │ │ │ ├── Dijkstra.java │ │ │ ├── Edge.java │ │ │ ├── Graph.java │ │ │ ├── Path.java │ │ │ ├── Point.java │ │ │ ├── Router.java │ │ │ └── package-info.java │ │ │ ├── tracker │ │ │ ├── TemporaryMemory.java │ │ │ ├── TrackerControl.java │ │ │ ├── TrackerServer.java │ │ │ └── package-info.java │ │ │ └── util │ │ │ ├── AbstractServer.java │ │ │ ├── PostgresSource.java │ │ │ ├── Quadruple.java │ │ │ ├── Quintuple.java │ │ │ ├── SampleReader.java │ │ │ ├── Sextuple.java │ │ │ ├── SourceException.java │ │ │ ├── Stopwatch.java │ │ │ ├── TimedSampleReader.java │ │ │ ├── Triple.java │ │ │ ├── Tuple.java │ │ │ └── package-info.java │ └── resources │ │ └── logback.xml └── test │ ├── java │ └── com │ │ └── bmwcarit │ │ └── barefoot │ │ ├── analysis │ │ ├── DBCANTest.java │ │ ├── DBRCANTest.java │ │ ├── DBSCANTest.java │ │ └── NYCSample.java │ │ ├── markov │ │ ├── FilterTest.java │ │ ├── KStateTest.java │ │ └── StateTest.java │ │ ├── matcher │ │ ├── MatcherExample.java │ │ ├── MatcherKStateTest.java │ │ ├── MatcherSampleTest.java │ │ ├── MatcherTest.java │ │ ├── MatcherTest.java.orig │ │ ├── MinsetTest.java │ │ └── ServerTest.java │ │ ├── road │ │ ├── BfmapReaderTest.java │ │ └── PostGISReaderTest.java │ │ ├── roadmap │ │ ├── RoadMapTest.java │ │ ├── RoadPointTest.java │ │ ├── RoadTest.java │ │ ├── RouteTest.java │ │ └── Testmap.java │ │ ├── spatial │ │ ├── GeographyTest.java │ │ ├── QuadTreeIndexTest.java │ │ └── SpatialExample.java │ │ ├── topology │ │ ├── DijkstraBenchmark.java │ │ ├── DijkstraTest.java │ │ ├── EdgeTest.java │ │ ├── GraphTest.java │ │ └── PathTest.java │ │ ├── tracker │ │ ├── TemporaryMemoryTest.java │ │ └── TrackerServerTest.java │ │ └── util │ │ └── AbstractServerTest.java │ └── resources │ ├── com │ └── bmwcarit │ │ └── barefoot │ │ ├── analysis │ │ └── xba96de419e711691b9445d6a6307c170.csv │ │ └── matcher │ │ ├── x0001-001.geojson │ │ ├── x0001-001.json │ │ ├── x0001-015.geojson │ │ └── x0001-015.json │ └── logback.xml ├── util ├── monitor │ ├── .gitignore │ ├── monitor.js │ ├── package.json │ └── public │ │ ├── index.html │ │ └── messages │ │ └── index.html ├── openjump │ ├── oberbayern-slim.jmp │ └── oberbayern.jmp └── submit │ ├── batch.py │ └── stream.py └── wiki └── Home.md /.gitignore: -------------------------------------------------------------------------------- 1 | internal/ 2 | doc/ 3 | target/ 4 | .project 5 | .pydevproject 6 | .settings/ 7 | .classpath 8 | .DS_Store 9 | *.osm.pbf 10 | *.bfmap 11 | *.pyc 12 | *.tar.gz 13 | *.synctex.gz 14 | *.log 15 | *.aux 16 | *~ 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: java 3 | jdk: 4 | # Build and test Barefoot library using JDK 7, 8 5 | - openjdk7 6 | - oraclejdk8 7 | matrix: 8 | include: 9 | - env: NAME="Matcher Server" 10 | before_script: 11 | - curl http://download.geofabrik.de/europe/germany/bayern/oberbayern-latest.osm.pbf --output map/osm/oberbayern.osm.pbf 12 | # Osmosis takes about 10 minutes to process the Oberbayern map used for testing, which coincides with 13 | # Travis' timeout for output updates. Use `travis_wait` to extend the timeout. 14 | # Use interactive option to force bash to read .bashrc and add path to Osmosis. 15 | - travis_wait docker exec barefoot-database /bin/bash -i /mnt/map/osm/import.sh 16 | # Start matcher server on port 1234 17 | - mvn --quiet -Dexec.executable="echo" -Dexec.args='-n ${project.version}' --non-recursive exec:exec > version 18 | - docker run -t -d --net=host --name="barefoot-matcher" -v ${PWD}:/mnt/barefoot --workdir /mnt/barefoot barefoot-map java -jar target/barefoot-`cat version`-matcher-jar-with-dependencies.jar --geojson config/server.properties config/oberbayern.properties 19 | - until sudo lsof -Pi :1234 -sTCP:LISTEN -t; do sleep 1; done 20 | - docker logs barefoot-matcher 21 | script: 22 | - python util/submit/batch.py --host localhost --port 1234 --file src/test/resources/com/bmwcarit/barefoot/matcher/x0001-015.json 23 | - python util/submit/batch.py --host localhost --port 1234 --file src/test/resources/com/bmwcarit/barefoot/matcher/x0001-001.json 24 | after_failure: 25 | - docker logs barefoot-matcher 26 | - env: NAME="Python Map Tools" 27 | install: true 28 | before_script: 29 | # Ensure PostgreSQL server is ready - for other tests, PostreSQL has plenty of time to start 30 | - until docker exec barefoot-database sudo --user=postgres -- psql --command='select 1;'; do sleep 1; done 31 | script: docker exec barefoot-database /bin/bash /mnt/map/tools/test/run.sh 32 | - env: NAME="Java Formatting" 33 | jdk: oraclejdk8 34 | before_install: true 35 | install: mvn formatter:format 36 | before_script: true 37 | script: 38 | - git diff --exit-code 39 | after_failure: true To fix this failure automatically, run "mvn formatter:format" on your code using Java 8+ 40 | services: 41 | - docker 42 | before_install: 43 | - docker build -t barefoot-map ./map 44 | # Stop existing PostgreSQL - https://github.com/travis-ci/travis-ci/issues/4842#issuecomment-311527059 45 | - sudo service postgresql stop 46 | # Start PostgreSQL in a container with Barefoot configuration 47 | - docker run -t -d --net=host --name="barefoot-database" -v ${PWD}/map/:/mnt/map barefoot-map 48 | before_script: 49 | - curl http://download.geofabrik.de/europe/germany/bayern/oberbayern-latest.osm.pbf --output map/osm/oberbayern.osm.pbf 50 | # Osmosis takes about 10 minutes to process the Oberbayern map used for testing, which coincides with 51 | # Travis' timeout for output updates. Use `travis_wait` to extend the timeout. 52 | # Use interactive option to force bash to read .bashrc and add path to Osmosis. 53 | - travis_wait docker exec barefoot-database /bin/bash -i /mnt/map/osm/import.sh 54 | script: 55 | - mvn test --batch-mode --errors 56 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | This product includes the following dependencies 2 | 3 | JUnit 4.11, which is available under a "Common Public License Version 1.0" license. 4 | For details, see deps/junit/ or https://github.com/junit-team/junit. 5 | 6 | JUnit 4.11, in turn, includes the following dependencies 7 | 8 | Hamcrest 1.3, which is available under a "BSD 3-Clause" license. 9 | For details, see deps/hamcrest/ or https://github.com/hamcrest/JavaHamcrest. 10 | 11 | ESRI Geometry API 1.1, which is available under a "Apache License 2.0" license. 12 | For details, see deps/esri-geometry-api/ or https://github.com/Esri/geometry-api-java. 13 | 14 | ESRI Geometry API 1.1, in turn, includes the following dependencies 15 | 16 | Java JSON 20090211, which is available under a "MIT License" license. 17 | For details, see deps/java-json/ or http://www.json.org/java/index.html. 18 | 19 | Jackson 1.9.12, which is available under a "Apache License 2.0" license. 20 | For details, see deps/jackson/. 21 | 22 | GeographicLib-Java 1.46, which is available under a "MIT License" license. 23 | For details, see deps/geographiclib/ or http://geographiclib.sourceforge.net/. 24 | 25 | Java JSON 20090211, which is available under a "MIT License" license. 26 | For details, see deps/java-json/ or http://www.json.org/java/index.html. 27 | 28 | PostgreSQL JDBC 9.2-1003-jdbc4, which is available under a "BSD 3-Clause" license. 29 | For details, see deps/postgresql-jdbc/ or http://jdbc.postgresql.org/about/license.html. 30 | 31 | SLF4J 1.7.10, which is available under a "MIT License" license. 32 | For details, see deps/slf4j/ or http://slf4j.org. 33 | 34 | Logback 1.0.9, which is available under a "LGPL 2.1" license. 35 | For details, see deps/logback/ or http://logback.qos.ch. 36 | 37 | Logback 1.0.9, in turn, includes the following dependencies 38 | 39 | SLF4J 1.7.10, which is available under a "MIT License" license. 40 | For details, see deps/slf4j/ or http://slf4j.org. 41 | 42 | Logback-core 1.0.9, which is available under a "LGPL 2.1" license. 43 | For details, see deps/logback/ or http://logback.qos.ch. 44 | 45 | JeroMQ 0.3.5, which is available under a "LGPL 3.0" license. 46 | For details, see deps/jeromq/ or https://github.com/zeromq/jeromq. -------------------------------------------------------------------------------- /config/oberbayern.properties: -------------------------------------------------------------------------------- 1 | database.host=localhost 2 | database.port=5432 3 | database.name=oberbayern 4 | database.table=bfmap_ways 5 | database.user=osmuser 6 | database.password=pass 7 | database.road-types=./map/tools/road-types.json 8 | -------------------------------------------------------------------------------- /config/server.properties: -------------------------------------------------------------------------------- 1 | server.port=1234 2 | server.timeout.request=15000 3 | server.timeout.response=60000 4 | server.connections=20 5 | matcher.sigma=10 6 | matcher.lambda=0.0 7 | matcher.distance.max=15000 8 | matcher.radius.max=200 9 | matcher.interval.min=1000 10 | matcher.distance.min=0 11 | matcher.threads=8 12 | matcher.shortenturns=true 13 | -------------------------------------------------------------------------------- /config/tracker.properties: -------------------------------------------------------------------------------- 1 | server.port=1234 2 | server.timeout.request=1000 3 | server.timeout.response=10000 4 | server.connections=100 5 | matcher.sigma=10 6 | matcher.lambda=0.0 7 | matcher.distance.max=5000 8 | matcher.radius.max=200 9 | matcher.interval.min=1000 10 | matcher.distance.min=0 11 | matcher.threads=8 12 | matcher.shortenturns=true 13 | tracker.state.ttl=60 14 | tracker.port=1235 15 | -------------------------------------------------------------------------------- /deps/geographiclib/license.txt: -------------------------------------------------------------------------------- 1 | This license applies to GeographicLib, versions 1.12 and later. 2 | 3 | Copyright (c) 2008-2014, Charles Karney 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | 25 | -------------------------------------------------------------------------------- /deps/hamcrest/license.txt: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | Copyright (c) 2000-2015 www.hamcrest.org 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | Redistributions of source code must retain the above copyright notice, this list of 10 | conditions and the following disclaimer. Redistributions in binary form must reproduce 11 | the above copyright notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution. 13 | 14 | Neither the name of Hamcrest nor the names of its contributors may be used to endorse 15 | or promote products derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 26 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 | DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /deps/java-json/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002 JSON.org 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | The Software shall be used for Good, not Evil. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /deps/logback/license.txt: -------------------------------------------------------------------------------- 1 | Logback: the reliable, generic, fast and flexible logging framework. 2 | Copyright (C) 1999-2012, QOS.ch. All rights reserved. 3 | 4 | This program and the accompanying materials are dual-licensed under 5 | either the terms of the Eclipse Public License v1.0 as published by 6 | the Eclipse Foundation 7 | 8 | or (per the licensee's choosing) 9 | 10 | under the terms of the GNU Lesser General Public License version 2.1 11 | as published by the Free Software Foundation. 12 | -------------------------------------------------------------------------------- /deps/postgresql-jdbc/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1997-2011, PostgreSQL Global Development Group 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 3. Neither the name of the PostgreSQL Global Development Group nor the names 13 | of its contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /deps/slf4j/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2013 QOS.ch 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /doc-files/build-pics.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # 4 | # Copyright (C) 2015, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | __author__ = "sebastian.mattheis@bmw-carit.de" 17 | __copyright__ = "Copyright 2015 BMW Car IT GmbH" 18 | __license__ = "Apache-2.0" 19 | 20 | import os 21 | 22 | for root, dirs, files in os.walk(".", topdown=False): 23 | for name in files: 24 | if name.endswith('.tex'): 25 | pic = os.path.splitext(name)[0] 26 | os.system("pdflatex -output-directory %s %s" % (root,os.path.join(root, pic + '.tex'))) 27 | os.system("pdfcrop %s %s" % (os.path.join(root, pic + '.pdf'), os.path.join(root, pic + '.pdf'))) 28 | os.system("convert -quality 100 -density 300 %s %s" % (os.path.join(root, pic + '.pdf'), os.path.join(root, pic + '.png'))) 29 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/analysis/dbscan-satellite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/analysis/dbscan-satellite.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-ecosystem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-ecosystem.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-ecosystem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-ecosystem.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-ecosystem.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{calc} 6 | 7 | \begin{document} 8 | \definecolor{globegreen}{RGB}{61,184,82} 9 | \definecolor{whaleblue}{RGB}{37,184,235} 10 | 11 | \begin{tikzpicture}[font=\sffamily] 12 | % Globe 13 | \node[align=center] at (1.5,6) {Map data \\ \scriptsize{(OpenStreetMap)}}; 14 | \node[circle,thick,fill=white!10!globegreen,minimum width=2cm] at (1.5,4.5) {}; 15 | \draw[thick,color=white!30!blue,fill=white!30!blue] ({1.5-sin(45)},{4.5+cos(45)}) to[bend left=30] (1.1,4.7) to[bend left=40] ({1.5-sin(45)},{4.5-cos(45)}) to (1.5,3.5) to[bend right=30] (1.7,4.7) to[bend left=45] ({1.5+sin(45)},{4.5+cos(45)}); 16 | \draw[thick,color=white!30!blue,fill=white!30!blue] (1.5,4.5) +(136:1) arc (136:44:1); 17 | \draw[thick,color=white!30!blue,fill=white!30!blue] (1.5,4.5) +(224:1) arc (224:271:1); 18 | \draw[thick] ({1.5-sin(45)},{4.5+cos(45)}) to[bend left=30] (1.1,4.7) to[bend left=40] ({1.5-sin(45)},{4.5-cos(45)}); 19 | \draw[thick] (1.5,3.5) to[bend right=30] (1.7,4.7) to[bend left=45] ({1.5+sin(45)},{4.5+cos(45)}); 20 | \node[draw,circle,thick,minimum width=2cm] at (1.5,4.5) {}; 21 | 22 | \draw[-latex,thick] (1.5,3.4) -- (1.5,3.0); % node[draw,midway,right=0.2cm,align=center,rectangle,rounded corners] {Barefoot map tools \\ \scriptsize(Python)}; 23 | 24 | % Docker whale 25 | \draw[thick,fill=white!20!whaleblue] (3.25,0.25) to[out=225,in=0] (2.5,0) to (0,0) to[out=270,in=180] (1.3,-1.3) to[out=0,in=235] (3.5,0) to[out=-45,in=225] (4.375,0.125) to[out=135,in=45] (3.575,0.325) to[out=45,in=-45] (3.375,1.125) to[out=225,in=135] (3.25,0.25); 26 | \node[draw,circle,thick,fill=white,inner sep=0pt,minimum size=5pt] at (1.4,-0.6) {}; 27 | \node[draw,circle,fill,inner sep=0pt,minimum size=2pt] at (1.4,-0.6) {}; 28 | \draw[thick,fill=white!80!whaleblue] (0.35,-0.9) to[bend left=-30] (1.2,-0.8) to[thick,bend left=-30] (1.3,-1.3) to[out=180,in=-45] (0.35,-0.9); 29 | 30 | % Docker container 31 | \draw[thick,rounded corners] (0.1,0.1) rectangle (2.9,2.9); 32 | \draw[thick] (1,0.5) to (1,1.5) to[bend left=30] (2.0,1.5) to[bend left=30] (1,1.5); 33 | \draw[thick] (2.0,1.5) to (2.0,0.5) to[bend left=30] (1.0,0.5); 34 | \node[align=center] at (1.5,2.25) {Barefoot map\\\scriptsize{(PostgreSQL/PostGIS)}}; 35 | 36 | % Barefoot libray 37 | \draw[thick,rounded corners] (5.1,0.1) rectangle (7.9,2.9); 38 | \node[align=center] at (6.5,2.25) {Barefoot library\\ \scriptsize{(JAR)}}; 39 | \node[text width=2.6cm] at (6.65,1.0) {\scriptsize{\begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt,parsep=0pt,partopsep=0pt,listparindent=0pt,itemindent=0pt,leftmargin=0pt,labelsep=2pt] 40 | \item{Map matching (online \& offline)} 41 | \item{Spatial data analysis on the map} 42 | \item{...} 43 | \end{itemize}} 44 | }; 45 | \draw[-latex,thick] (3.2,1.5) to (4.8,1.5); 46 | 47 | % Stand-alone matcher 48 | \draw[thick,rounded corners] (10.1,3.1) rectangle (12.9,5.9); 49 | \node[align=center] at (11.5,4.6) {Barefoot servers \\ \scriptsize{(stand-alone)} \\ \scriptsize{offline (\textbf{matcher}) and} \\ \scriptsize{online/real-time map} \\ \scriptsize{matching (\textbf{tracker})}}; 50 | \draw[-latex,thick] (8.2,2) to (9.8,4.5); 51 | 52 | % Online map matching 53 | \draw[thick,dashed,rounded corners] (10.1,0.1) rectangle (12.9,2.9); 54 | \node[align=center] at (11.5,1.75) {Scalable offline \\ map matching \\ \scriptsize{(Spark, Hadoop)}}; 55 | \draw[-latex,thick,dashed] (8.2,1.5) to (9.8,1.5); 56 | 57 | % Scalable offline map matching 58 | \draw[thick,dashed,rounded corners] (10.1,-2.9) rectangle (12.9,-0.1); 59 | \node[align=center] at (11.5,-1.25) {Scalable online \\ map matching \\ \scriptsize{(Storm, Spark} \\ \scriptsize{Streaming)}}; 60 | \draw[-latex,thick,dashed] (8.2,1) to (9.8,-1.5); 61 | \end{tikzpicture} 62 | \end{document} 63 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-lib-dependencies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-lib-dependencies.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-lib-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-lib-dependencies.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-lib-dependencies.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} % Required for drawings 3 | \usetikzlibrary{positioning,calc} 4 | 5 | \newcommand{\easttowest}[4]{ 6 | \draw[-latex] (#1.east) -| ($ (#1.east) + (#3,0) $) |- node[near end, above]{#4} (#2.west); 7 | } 8 | 9 | \newcommand{\easttoeast}[4]{ 10 | \draw[-latex] (#1.east) -| ($ (#1.east) + (#3,0) $) |- node[near end, above]{#4} (#2.east); 11 | } 12 | 13 | \begin{document} 14 | \tikzstyle{box}=[draw, rectangle, minimum height=1.5cm, minimum width=3.5cm,align=center] 15 | 16 | \begin{tikzpicture}[font=\sffamily] 17 | \node[box] (barefoot) at (2,0) {Barefoot lib (Java) \\ \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 18 | \node[box] (esri) at (8,0) {ESRI Geometry API \\ \footnotesize{(1.1)} \\ \footnotesize{Apache-2.0}}; 19 | \node[box] (jackson) at (14, 0) {Jackson \\ \footnotesize{(1.9.12)} \\ \footnotesize{MIT License}}; 20 | \node[box] (geolib) at (8,-2) {GeographicLib-Java \\ \footnotesize{(1.43)} \\ \footnotesize{MIT License}}; 21 | \node[box] (json) at (8,-4) {Java JSON \\ \footnotesize{(20090211)} \\ \footnotesize{MIT License}}; 22 | \node[box] (jdbc) at (8,-6) {PostgreSQL JDBC \\ \footnotesize{(9.2-1003-jdbc4)} \\ \footnotesize{BSD 3-Clause}}; 23 | \node[box] (junit) at (8,-8) {JUnit \\ \footnotesize{(4.11)} \\ \footnotesize{CPL-1.0}}; 24 | \node[box] (hamcrest) at (14,-8) {Hamcrest \\ \footnotesize{(1.3)} \\ \footnotesize{BSD 3-Clause}}; 25 | \node[box] (slf4j) at (8,-10) {SLF4J \\ \footnotesize{(1.7.10)} \\ \footnotesize{MIT License}}; 26 | \node[box] (logback) at (8,-12) {Logback \\ \footnotesize{(1.0.9)} \\ \footnotesize{LGPL-2.1}}; 27 | \node[box] (logback-core) at (14,-12) {Logback-Core \\ \footnotesize{(1.0.9)} \\ \footnotesize{LGPL-2.1}}; 28 | \node[box] (jeromq) at (8,-14) {JeroMQ \\ \footnotesize{(0.3.5)} \\ \footnotesize{LGPL-3.0}}; 29 | 30 | \easttowest{barefoot}{esri}{0.5}{{\footnotesize{dynamic}}} 31 | \easttowest{esri}{jackson}{0.5}{{\footnotesize{dynamic}}} 32 | \easttoeast{esri}{json}{2.0}{{\footnotesize{dynamic}}} 33 | \easttowest{barefoot}{geolib}{0.5}{{\footnotesize{dynamic}}} 34 | \easttowest{barefoot}{json}{0.5}{{\footnotesize{dynamic}}} 35 | \easttowest{barefoot}{jdbc}{0.5}{{\footnotesize{dynamic}}} 36 | \easttowest{barefoot}{junit}{0.5}{{\footnotesize{dynamic}}} 37 | \easttowest{junit}{hamcrest}{0.5}{{\footnotesize{dynamic}}} 38 | \easttowest{barefoot}{slf4j}{0.5}{{\footnotesize{dynamic}}} 39 | \easttowest{barefoot}{logback}{0.5}{{\footnotesize{dynamic}}} 40 | \easttowest{logback}{logback-core}{0.5}{{\footnotesize{dynamic}}} 41 | \easttoeast{logback}{slf4j}{2.0}{{\footnotesize{dynamic}}} 42 | \easttowest{barefoot}{jeromq}{0.5}{{\footnotesize{dynamic}}} 43 | \end{tikzpicture} 44 | \end{document} 45 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-map-dependencies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-map-dependencies.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-map-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-map-dependencies.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-map-dependencies.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} % Required for drawings 3 | \usetikzlibrary{positioning,calc} 4 | 5 | \newcommand{\easttowest}[4]{ 6 | \draw[-latex] (#1.east) -| ($ (#1.east) + (#3,0) $) |- node[near end, above]{#4} (#2.west); 7 | } 8 | 9 | \begin{document} 10 | \tikzstyle{box}=[draw, rectangle, minimum height=1.5cm, minimum width=3.5cm,align=center] 11 | 12 | \begin{tikzpicture}[font=\sffamily] 13 | \node[box] (server) at (2,0) {Map server (container) \\ \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 14 | 15 | \node[box] (docker) at (8,0) {Docker \\ \footnotesize{(1.6)} \\ \footnotesize{Apache-2.0}}; 16 | \node[box] (postgresql) at (8,-2) {PostgreSQL \\ \footnotesize{(9.3)} \\ \footnotesize{PostgreSQL License}}; 17 | \node[box] (postgis) at (8,-4) {PostGIS \\ \footnotesize{(2.1)} \\ \footnotesize{GPL-2.0}}; 18 | \node[box] (osmosis) at (8,-6) {Osmosis \\ \footnotesize{(0.43.1)} \\ \footnotesize{GPL-3}}; 19 | \node[box] (osm) at (8,-8) {OpenStreetMap \\ \footnotesize{(any dump)} \\ \footnotesize{ODbL}}; 20 | 21 | \easttowest{server}{docker}{0.5}{{\footnotesize{usage}}} 22 | \easttowest{server}{postgresql}{0.5}{{\footnotesize{usage}}} 23 | \easttowest{server}{postgis}{0.5}{{\footnotesize{usage}}} 24 | \easttowest{server}{osmosis}{0.5}{{\footnotesize{usage}}} 25 | \easttowest{server}{osm}{0.5}{{\footnotesize{usage}}} 26 | 27 | \node[box] (tools) at (2,-10) {Map tools (Python) \\ \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 28 | \node[box] (psycopg) at (8,-10) {Psycopg \\ \footnotesize{(2.4.5)} \\ \footnotesize{LGPL-3.0}}; 29 | \node[box] (gdal) at (8,-12) {GDAL \\ \footnotesize{(1.10)} \\ \footnotesize{MIT License}}; 30 | \node[box] (numpy) at (8,-14) {NumPy \\ \footnotesize{(1.6.1)} \\ \footnotesize{BSD 3-Clause}}; 31 | \node[box] (python) at (8,-16) {Python Std. Libary \\ \footnotesize{(2.7.3)} \\ \footnotesize{Python License}}; 32 | 33 | \draw[-latex] (server) -- node[right]{\footnotesize{usage}} (tools); 34 | \easttowest{tools}{psycopg}{0.5}{{\footnotesize{dynamic}}} 35 | \easttowest{tools}{gdal}{0.5}{{\footnotesize{dynamic}}} 36 | \easttowest{tools}{numpy}{0.5}{{\footnotesize{dynamic}}} 37 | \easttowest{tools}{python}{0.5}{{\footnotesize{dynamic}}} 38 | \end{tikzpicture} 39 | \end{document} 40 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-util-dependencies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-util-dependencies.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-util-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/barefoot-util-dependencies.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/barefoot-util-dependencies.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} % Required for drawings 3 | \usetikzlibrary{positioning,calc} 4 | 5 | \newcommand{\easttowest}[4]{ 6 | \draw[-latex] (#1.east) -| ($ (#1.east) + (#3,0) $) |- node[near end, above]{#4} (#2.west); 7 | } 8 | 9 | \newcommand{\easttoeast}[4]{ 10 | \draw[-latex] (#1.east) -| ($ (#1.east) + (#3,0) $) |- node[near end, above]{#4} (#2.east); 11 | } 12 | 13 | \begin{document} 14 | \tikzstyle{box}=[draw, rectangle, minimum height=1.5cm, minimum width=3.5cm,align=center] 15 | 16 | \begin{tikzpicture}[font=\sffamily] 17 | \node[box] (barefoot-node) at (2,0) {Barefoot monitor \\ (NodeJS) \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 18 | \node[box] (socket) at (8,0) {Socket.io \\ \footnotesize{(1.4.4)} \\ \footnotesize{MIT License}}; 19 | \node[box] (socketsub) at (14,0) {sub packages \\ \footnotesize{MIT License}}; 20 | \node[box] (express) at (8,-2) {Express.js \\ \footnotesize{(4.13.4)} \\ \footnotesize{MIT License}}; 21 | \node[box] (expresssub) at (14,-2) {sub packages \\ \footnotesize{(MIT License)}}; 22 | \node[box] (inherits) at (14,-4) {inherits \\ \footnotesize{(2.0.1)} \\ \footnotesize{ISC License}}; 23 | \node[box] (qs) at (14,-6) {qs \\ \footnotesize{(4.0.0)} \\ \footnotesize{BSD 3-Clause}}; 24 | \node[box] (zeromq-node) at (8,-8) {ZeroMQ (NodeJS) \\ \footnotesize{(2.14.0)} \\ \footnotesize{MIT License}}; 25 | \node[box] (zeromq-cxx) at (14,-8) {ZeroMQ (C++) \\ \footnotesize{(2.2.0)} \\ \footnotesize{LGPL-3.0}}; 26 | 27 | \easttowest{barefoot-node}{socket}{0.5}{{\footnotesize{dynamic}}} 28 | \easttowest{socket}{socketsub}{0.5}{{\footnotesize{dynamic}}} 29 | \easttowest{barefoot-node}{express}{0.5}{{\footnotesize{dynamic}}} 30 | \easttowest{express}{expresssub}{0.5}{{\footnotesize{dynamic}}} 31 | \easttowest{express}{inherits}{0.5}{{\footnotesize{dynamic}}} 32 | \easttowest{express}{qs}{0.5}{{\footnotesize{dynamic}}} 33 | \easttowest{barefoot-node}{zeromq-node}{0.5}{{\footnotesize{dynamic}}} 34 | \easttowest{zeromq-node}{zeromq-cxx}{0.5}{{\footnotesize{dynamic}}} 35 | 36 | \node[box] (barefoot-js) at (2,-10) {Barefoot monitor (JS) \\ \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 37 | \node[box] (openlayers) at (8,-10) {OpenLayers 3 \\ \footnotesize{BSD 2-Clause}}; 38 | \node[box] (jquery) at (8,-12) {jQuery \\ \footnotesize{MIT License}}; 39 | \node[box] (socketjs) at (8,-14) {Socket.io.js \\ \footnotesize{MIT License}}; 40 | 41 | \easttowest{barefoot-js}{openlayers}{0.5}{{\footnotesize{dynamic}}} 42 | \easttowest{barefoot-js}{jquery}{0.5}{{\footnotesize{dynamic}}} 43 | \easttowest{barefoot-js}{socketjs}{0.5}{{\footnotesize{dynamic}}} 44 | 45 | \node[box] (barefoot-submit) at (2,-16) {Barefoot submit (Python) \\ \footnotesize{(0.1.0)} \\ \footnotesize{Apache-2.0}}; 46 | \node[box] (python) at (8,-16) {Python Std. Libary \\ \footnotesize{(2.7.3)} \\ \footnotesize{Python License}}; 47 | \node[box] (requests) at (8,-18) {Requests \\ \footnotesize{(2.6.2)} \\ \footnotesize{Apache-2.0}}; 48 | 49 | \easttowest{barefoot-submit}{python}{0.5}{{\footnotesize{dynamic}}} 50 | \easttowest{barefoot-submit}{requests}{0.5}{{\footnotesize{dynamic}}} 51 | \end{tikzpicture} 52 | \end{document} 53 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-1.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-1.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | 21 | \node[gstate] (s00) at (1,0) {}; 22 | \node[gstate] (s01) at (1,1) {}; 23 | \node[gstate,ultra thick] (s02) at (1,2) {}; 24 | \node[gstate] (s03) at (1,3) {}; 25 | 26 | \draw[mygreen,very thick] (0.5,4) rectangle (1.5,-1); 27 | \end{tikzpicture} 28 | \end{document} 29 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-2.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-2.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | \node at (2,4.5){$\mathcal{S}_1$}; 21 | 22 | \node[gstate] (s00) at (1,0) {}; 23 | \node[gstate] (s01) at (1,1) {}; 24 | \node[gstate,ultra thick] (s02) at (1,2) {}; 25 | \node[gstate] (s03) at (1,3) {}; 26 | 27 | \node[state] (s10) at (2,-0.5) {}; 28 | \node[state] (s11) at (2,0.5) {}; 29 | \node[state] (s12) at (2,1.5) {}; 30 | \node[state] (s13) at (2,2.5) {}; 31 | \node[state] (s14) at (2,3.5) {}; 32 | 33 | \draw[edge] (s00) -- (s10); 34 | \draw[edge] (s00) -- (s11); 35 | \draw[edge] (s00) -- (s12); 36 | \draw[edge] (s02) -- (s13); 37 | \draw[edge] (s02) -- (s14); 38 | 39 | \draw[mygreen,very thick] (0.5,4) rectangle (1.5,-1); 40 | \end{tikzpicture} 41 | \end{document} 42 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-3.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-3.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-3.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | \node at (2,4.5){$\mathcal{S}_1$}; 21 | 22 | \node[gstate] (s00) at (1,0) {}; 23 | \node[gstate, dashed] (s01) at (1,1) {}; 24 | \node[gstate] (s02) at (1,2) {}; 25 | \node[gstate, dashed] (s03) at (1,3) {}; 26 | 27 | \node[gstate] (s10) at (2,-0.5) {}; 28 | \node[gstate,ultra thick] (s11) at (2,0.5) {}; 29 | \node[gstate] (s12) at (2,1.5) {}; 30 | \node[gstate] (s13) at (2,2.5) {}; 31 | \node[gstate] (s14) at (2,3.5) {}; 32 | 33 | \draw[gedge] (s00) -- (s10); 34 | \draw[gedge] (s00) -- (s11); 35 | \draw[gedge,ultra thick] (s00) -- (s12); 36 | \draw[gedge] (s02) -- (s13); 37 | \draw[gedge] (s02) -- (s14); 38 | 39 | \draw[mygreen,very thick] (1.5,4) rectangle (2.5,-1); 40 | \end{tikzpicture} 41 | \end{document} 42 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-4.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-4.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-4.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | \node at (2,4.5){$\mathcal{S}_1$}; 21 | 22 | \node[gstate] (s00) at (1,0) {}; 23 | \node[gstate] (s02) at (1,2) {}; 24 | 25 | \node[gstate] (s10) at (2,-0.5) {}; 26 | \node[gstate,ultra thick] (s11) at (2,0.5) {}; 27 | \node[gstate] (s12) at (2,1.5) {}; 28 | \node[gstate] (s13) at (2,2.5) {}; 29 | \node[gstate] (s14) at (2,3.5) {}; 30 | 31 | \draw[gedge] (s00) -- (s10); 32 | \draw[gedge] (s00) -- (s11); 33 | \draw[gedge,ultra thick] (s00) -- (s12); 34 | \draw[gedge] (s02) -- (s13); 35 | \draw[gedge] (s02) -- (s14); 36 | 37 | \draw[mygreen,very thick] (1.5,4) rectangle (2.5,-1); 38 | \end{tikzpicture} 39 | \end{document} 40 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-5.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-5.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-5.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | \node at (2,4.5){$\mathcal{S}_1$}; 21 | \node at (3,4.5){$\mathcal{S}_2$}; 22 | 23 | \node[gstate] (s00) at (1,0) {}; 24 | \node[gstate] (s02) at (1,2) {}; 25 | 26 | \node[gstate] (s10) at (2,-0.5) {}; 27 | \node[gstate,ultra thick] (s11) at (2,0.5) {}; 28 | \node[gstate] (s12) at (2,1.5) {}; 29 | \node[gstate] (s13) at (2,2.5) {}; 30 | \node[gstate] (s14) at (2,3.5) {}; 31 | 32 | \draw[gedge] (s00) -- (s10); 33 | \draw[gedge] (s00) -- (s11); 34 | \draw[gedge,ultra thick] (s00) -- (s12); 35 | \draw[gedge] (s02) -- (s13); 36 | \draw[gedge] (s02) -- (s14); 37 | 38 | \node[state] (s20) at (3,0) {}; 39 | \node[state] (s21) at (3,1) {}; 40 | \node[state] (s22) at (3,2) {}; 41 | 42 | \draw[edge] (s11) -- (s20); 43 | \draw[edge] (s11) -- (s21); 44 | \draw[edge] (s11) -- (s22); 45 | 46 | \draw[mygreen,very thick] (1.5,4) rectangle (2.5,-1); 47 | \end{tikzpicture} 48 | \end{document} 49 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-6.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/kstate-6.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/kstate-6.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \definecolor{mygreen}{rgb}{0,0.6,0} 9 | 10 | \begin{document} 11 | \tikzstyle{state}=[draw,shape=circle] 12 | \tikzstyle{gstate}=[draw,shape=circle,mygreen] 13 | \tikzstyle{edge}=[draw,latex'-] 14 | \tikzstyle{gedge}=[draw,latex'-,mygreen] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw[opacity=0.0,very thick] (0.5,4) rectangle (3.5,-1); 18 | 19 | \node at (1,4.5){$\mathcal{S}_0$}; 20 | \node at (2,4.5){$\mathcal{S}_1$}; 21 | \node at (3,4.5){$\mathcal{S}_2$}; 22 | 23 | \node[gstate] (s00) at (1,0) {}; 24 | \node[gstate,dashed] (s02) at (1,2) {}; 25 | 26 | \node[gstate,dashed] (s10) at (2,-0.5) {}; 27 | \node[gstate] (s11) at (2,0.5) {}; 28 | \node[gstate,dashed] (s12) at (2,1.5) {}; 29 | \node[gstate,dashed] (s13) at (2,2.5) {}; 30 | \node[gstate,dashed] (s14) at (2,3.5) {}; 31 | 32 | \draw[gedge,dashed] (s00) -- (s10); 33 | \draw[gedge,ultra thick] (s00) -- (s11); 34 | \draw[gedge,dashed] (s00) -- (s12); 35 | \draw[gedge,dashed] (s02) -- (s13); 36 | \draw[gedge,dashed] (s02) -- (s14); 37 | 38 | \node[gstate,ultra thick] (s20) at (3,0) {}; 39 | \node[gstate] (s21) at (3,1) {}; 40 | \node[gstate] (s22) at (3,2) {}; 41 | 42 | \draw[gedge] (s11) -- (s20); 43 | \draw[gedge,ultra thick] (s11) -- (s21); 44 | \draw[gedge] (s11) -- (s22); 45 | 46 | \draw[mygreen,very thick] (2.5,4) rectangle (3.5,-1); 47 | \end{tikzpicture} 48 | \end{document} 49 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/model.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/markov/model.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/markov/model.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \begin{document} 9 | \tikzstyle{state}=[draw,shape=circle,minimum size=10mm,inner sep=0pt] 10 | \tikzstyle{emission}=[] 11 | \tikzstyle{transition}=[draw,-latex'] 12 | 13 | \begin{tikzpicture}[font=\sffamily] 14 | \node at (0,4.5) {$\mathbf{\mathcal{S}_{0}}$}; 15 | \node at (2,4.5) {$\mathcal{S}_{1}$}; 16 | \node at (4,4.5) {$\dots$}; 17 | \node at (6,4.5) {$\mathcal{S}_{T-1}$}; 18 | \node at (8,4.5) {$\mathcal{S}_{T}$}; 19 | 20 | \node[state] (r00) at (0,3.5) {$s^1_{0}$}; 21 | \node[state] (r01) at (0,2) {$s^2_{0}$}; 22 | \node (r02) at (0,1.1) {$\vdots$}; 23 | \node[state] (r03) at (0,0) {$s^{n_0}_{0}$}; 24 | 25 | \node[state] (r10) at (2,3.5) {$s^1_{1}$}; 26 | \node[state] (r11) at (2,2) {$s^2_{1}$}; 27 | \node (r12) at (2,1.1) {$\vdots$}; 28 | \node[state] (r13) at (2,0) {$s^{n_1}_{1}$}; 29 | 30 | \node[state,dashed] (r20) at (4,3.5) {$\dots$}; 31 | \node[state,dashed] (r21) at (4,2) {$\dots$}; 32 | 33 | \node[state,dashed] (r23) at (4,0) {$\dots$}; 34 | 35 | \node[state] (r30) at (6,3.5) {$s^1_{T-1}$}; 36 | \node[state] (r31) at (6,2) {$s^2_{T-1}$}; 37 | \node (r32) at (6,1.1) {$\vdots$}; 38 | \node[state] (r33) at (6,0) {$s^{n_{T-1}}_{T-1}$}; 39 | 40 | \node[state] (r40) at (8,3.5) {$s^1_{T}$}; 41 | \node[state] (r41) at (8,2) {$s^2_{T}$}; 42 | \node (r42) at (8,1.1) {$\vdots$}; 43 | \node[state] (r43) at (8,0) {$s^{n_T}_{T}$}; 44 | 45 | \path[transition] (r00) to (r10); 46 | \path[transition] (r00) to (r11); 47 | \path[transition] (r00) to (r13); 48 | \path[transition] (r01) to (r10); 49 | \path[transition] (r01) to (r11); 50 | \path[transition] (r01) to (r13); 51 | \path[transition] (r03) to (r10); 52 | \path[transition] (r03) to (r11); 53 | \path[transition] (r03) to (r13); 54 | 55 | \path[transition,dashed] (r10) to (r20); 56 | \path[transition,dashed] (r10) to (r21); 57 | \path[transition,dashed] (r10) to (r23); 58 | \path[transition,dashed] (r11) to (r20); 59 | \path[transition,dashed] (r11) to (r21); 60 | \path[transition,dashed] (r11) to (r23); 61 | \path[transition,dashed] (r13) to (r20); 62 | \path[transition,dashed] (r13) to (r21); 63 | \path[transition,dashed] (r13) to (r23); 64 | 65 | \path[transition,dashed] (r20) to (r30); 66 | \path[transition,dashed] (r20) to (r31); 67 | \path[transition,dashed] (r20) to (r33); 68 | \path[transition,dashed] (r21) to (r30); 69 | \path[transition,dashed] (r21) to (r31); 70 | \path[transition,dashed] (r21) to (r33); 71 | \path[transition,dashed] (r23) to (r30); 72 | \path[transition,dashed] (r23) to (r31); 73 | \path[transition,dashed] (r23) to (r33); 74 | 75 | \path[transition] (r30) to (r40); 76 | \path[transition] (r30) to (r41); 77 | \path[transition] (r30) to (r43); 78 | \path[transition] (r31) to (r40); 79 | \path[transition] (r31) to (r41); 80 | \path[transition] (r31) to (r43); 81 | \path[transition] (r33) to (r40); 82 | \path[transition] (r33) to (r41); 83 | \path[transition] (r33) to (r43); 84 | \end{tikzpicture} 85 | \end{document} 86 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/benchmark/benchmark.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/matcher/benchmark/benchmark.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/benchmark/benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/matcher/benchmark/benchmark.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/matcher-components.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/matcher/matcher-components.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/matcher-components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/matcher/matcher-components.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/matcher-components.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{arrows} 6 | \usetikzlibrary{calc} 7 | 8 | \begin{document} 9 | \tikzstyle{box}=[draw, rectangle, minimum height=1.5cm, minimum width=2.8cm] 10 | \tikzstyle{flow}=[-latex,draw] 11 | 12 | \begin{tikzpicture}[font=\sffamily] 13 | \node (source) at (0,2.5) {}; 14 | \node (sink) at (12,2.5) {}; 15 | 16 | \node[box,align=center] (filter) at (3.5,2.5) {Matcher}; 17 | \node[box,align=center] (state) at (8.5,2.5) {State}; 18 | 19 | \node[box,align=center] (map) at (3.5,0) {Map}; 20 | \node[box,align=center] (router) at (8.5,0) {Router}; 21 | 22 | \draw[flow] (source) to node[above]{$z_t$} (filter); 23 | \draw[flow] (state) to node[above]{$\bar{s}_t$} node[below]{$(s_0 \dots s_t)$} (sink); 24 | 25 | \draw[flow,transform canvas={yshift=0.1cm}] (state) to node[above]{$\mathcal{S}_{t-1}, z_{t-1}$} (filter); 26 | \draw[flow,transform canvas={yshift=-0.1cm}] (filter) to node[below]{$\mathcal{S}_{t}, z_t, p$} (state); 27 | 28 | \draw[flow,transform canvas={xshift=-0.1cm}] (filter) to node[left]{$z_t$} (map); 29 | \draw[flow,transform canvas={xshift=0.1cm}] (map) to node[right]{$\mathcal{S}_t$} (filter); 30 | 31 | \draw[flow,transform canvas={xshift=-0.08cm,yshift=-0.08cm}] (filter) to node[left,yshift=-0.1cm]{$(s_{t-1},s_t)$} (router); 32 | \draw[flow,transform canvas={xshift=0.08cm,yshift=0.08cm}] (router) to node[right,yshift=0.1cm]{$\langle s_{t-1},s_t \rangle$} (filter); 33 | \end{tikzpicture} 34 | \end{document} 35 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/matcher/matching-satellite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/matcher/matching-satellite.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/spatial/intercept-satellite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/spatial/intercept-satellite.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/spatial/radius-satellite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/spatial/radius-satellite.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/spatial/radius.geojson-io.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "properties": { 7 | "marker-color": "#ff8a00", 8 | "marker-size": "small", 9 | "marker-symbol": "circle" 10 | }, 11 | "geometry": { 12 | "type": "Point", 13 | "coordinates": [ 14 | 11.55036221198873, 15 | 48.03380119321967 16 | ] 17 | } 18 | }, 19 | { 20 | "type": "Feature", 21 | "properties": { 22 | "stroke": "#ff8a00", 23 | "stroke-width": 8, 24 | "stroke-opacity": 0.6, 25 | "marker-size": "" 26 | }, 27 | "geometry": { 28 | "type": "LineString", 29 | "coordinates": [ 30 | [ 31 | 11.5510154, 32 | 48.0337025 33 | ], 34 | [ 35 | 11.550549, 36 | 48.0337719 37 | ], 38 | [ 39 | 11.550234, 40 | 48.0338213 41 | ] 42 | ] 43 | } 44 | }, 45 | { 46 | "type": "Feature", 47 | "properties": { 48 | "marker-color": "#33b13a", 49 | "marker-size": "small", 50 | "marker-symbol": "circle" 51 | }, 52 | "geometry": { 53 | "type": "Point", 54 | "coordinates": [ 55 | 11.550892751563895, 56 | 48.034193059641936 57 | ] 58 | } 59 | }, 60 | { 61 | "type": "Feature", 62 | "properties": { 63 | "stroke": "#33b13a", 64 | "stroke-width": 8, 65 | "stroke-opacity": 0.6 66 | }, 67 | "geometry": { 68 | "type": "LineString", 69 | "coordinates": [ 70 | [ 71 | 11.5510154, 72 | 48.0337025 73 | ], 74 | [ 75 | 11.5510294, 76 | 48.0337582 77 | ], 78 | [ 79 | 11.5510399, 80 | 48.0337968 81 | ], 82 | [ 83 | 11.5507286, 84 | 48.0346351 85 | ] 86 | ] 87 | } 88 | }, 89 | { 90 | "type": "Feature", 91 | "properties": { 92 | "marker-color": "#2c33c1", 93 | "marker-size": "small", 94 | "marker-symbol": "circle" 95 | }, 96 | "geometry": { 97 | "type": "Point", 98 | "coordinates": [ 99 | 11.550234, 100 | 48.0338213 101 | ] 102 | } 103 | }, 104 | { 105 | "type": "Feature", 106 | "properties": { 107 | "stroke": "#2c33c1", 108 | "stroke-width": 8, 109 | "stroke-opacity": 0.6 110 | }, 111 | "geometry": { 112 | "type": "LineString", 113 | "coordinates": [ 114 | [ 115 | 11.550234, 116 | 48.0338213 117 | ], 118 | [ 119 | 11.5495725, 120 | 48.0339445 121 | ], 122 | [ 123 | 11.5491112, 124 | 48.0340447 125 | ], 126 | [ 127 | 11.5487517, 128 | 48.0341259 129 | ] 130 | ] 131 | } 132 | }, 133 | { 134 | "type": "Feature", 135 | "properties": { 136 | "marker-color": "#e92821", 137 | "marker-size": "large", 138 | "marker-symbol": "cross" 139 | }, 140 | "geometry": { 141 | "type": "Point", 142 | "coordinates": [ 143 | 11.550474464893341, 144 | 48.034123185269095 145 | ] 146 | } 147 | } 148 | ] 149 | } -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph-route.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/topology/graph-route.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph-route.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/topology/graph-route.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph-route.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} % Required for drawings 3 | \usetikzlibrary{positioning} % Required for node positioning, e.g. 'above right=of' 4 | \usepackage{helvet} 5 | \usepackage[eulergreek]{sansmath} 6 | 7 | \begin{document} 8 | \tikzstyle{node}=[draw,circle,minimum size=0.8cm,node distance=1.5cm,font=\sansmath\sffamily] 9 | \tikzstyle{label}=[font=\small\sansmath\sffamily,inner sep=1pt] 10 | \tikzstyle{edge}=[-latex] 11 | \tikzstyle{route}=[line width=2.5pt,red,opacity=0.6] 12 | 13 | \begin{tikzpicture} 14 | \node [node] (0) {0}; 15 | \node [node, above right=of 0] (1) {1}; 16 | \node [node, below right=of 0] (2) {2}; 17 | \node [node, right=of 1] (3) {3}; 18 | \node [node, right=of 2] (4) {4}; 19 | \node [node, below right=of 3] (5) {5}; 20 | 21 | \draw[edge] (0.30) to node[label,below right] {(0,3)} (1.-120); 22 | \draw[edge] (1.-150) to node[label,above left] {(1,3)} (0.60); 23 | \draw[edge] (0) to node[label,above right] {(2,4)} (2); 24 | \draw[edge] (3) to node[label,above] {(3,4)} (1); 25 | \draw[edge] (1.-70) to node[label,below left] {(4,2)} (4.140); 26 | \draw[edge] (4.110) to node[pos=0.75,label,above right] {(5,2)} (1.-40); 27 | \draw[edge] (2) to node[label,above] {(6,6)} (4); 28 | \draw[edge] (3.-105) to node[pos=0.3,label,left] {(7,4)} (4.105); 29 | \draw[edge] (4.75) to node[label,right] {(8,4)} (3.-75); 30 | \draw[edge] (3) to node[label,above right] {(9,3)} (5); 31 | \draw[edge] (5) to node[label,below right] {(10,3)} (4); 32 | 33 | \draw[route,shorten <={3 * 0.14cm}] (0.30) to (1.-120); 34 | \draw[route] (1.-70) to (4.140); 35 | \draw[route] (4.75) to (3.-75); 36 | \draw[route,shorten >={3 * 0.14cm}] (3) to (5); 37 | \end{tikzpicture} 38 | \end{document} 39 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/topology/graph.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/topology/graph.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/topology/graph.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{tikz} % Required for drawings 3 | \usetikzlibrary{positioning} % Required for node positioning, e.g. 'above right=of' 4 | \usepackage{helvet} 5 | \usepackage[eulergreek]{sansmath} 6 | 7 | \begin{document} 8 | \tikzstyle{node}=[draw,circle,minimum size=0.8cm,node distance=1.5cm,font=\sansmath\sffamily] 9 | \tikzstyle{label}=[font=\small\sansmath\sffamily,inner sep=1pt] 10 | \tikzstyle{edge}=[-latex] 11 | 12 | \begin{tikzpicture} 13 | \node [node] (0) {0}; 14 | \node [node, above right=of 0] (1) {1}; 15 | \node [node, below right=of 0] (2) {2}; 16 | \node [node, right=of 1] (3) {3}; 17 | \node [node, right=of 2] (4) {4}; 18 | \node [node, below right=of 3] (5) {5}; 19 | 20 | \draw[edge] (0.30) to node[label,below right] {(0,3)} (1.-120); 21 | \draw[edge] (1.-150) to node[label,above left] {(1,3)} (0.60); 22 | \draw[edge] (0) to node[label,above right] {(2,4)} (2); 23 | \draw[edge] (3) to node[label,above] {(3,4)} (1); 24 | \draw[edge] (1.-70) to node[label,below left] {(4,2)} (4.140); 25 | \draw[edge] (4.110) to node[pos=0.75,label,above right] {(5,2)} (1.-40); 26 | \draw[edge] (2) to node[label,above] {(6,6)} (4); 27 | \draw[edge] (3.-105) to node[pos=0.3,label,left] {(7,4)} (4.105); 28 | \draw[edge] (4.75) to node[label,right] {(8,4)} (3.-75); 29 | \draw[edge] (3) to node[label,above right] {(9,3)} (5); 30 | \draw[edge] (5) to node[label,below right] {(10,3)} (4); 31 | \end{tikzpicture} 32 | \end{document} 33 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/monitor-1152x864.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/monitor-1152x864.gif -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/monitor-1600x1000.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/monitor-1600x1000.gif -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-monitor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/tracker-monitor.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/tracker-monitor.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-monitor.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{calc} 6 | 7 | \begin{document} 8 | \definecolor{globegreen}{RGB}{61,184,82} 9 | \definecolor{whaleblue}{RGB}{37,184,235} 10 | 11 | \begin{tikzpicture}[font=\sffamily] 12 | % \draw[-latex,thick] (-1.8,1.5) to node[above,midway,align=center] {\footnotesize{Position updates} \\ \tiny{(object id, position, time)}} (-0.2,1.5); 13 | % \node at (-1,1.1) {$\vdots$}; 14 | % \draw[-latex,thick] (-1.8,0.5) to (-0.2,0.5); 15 | 16 | % Barefoot tracker 17 | \draw[thick,rounded corners,fill={rgb:red,25;green,51;blue,0},opacity=0.3] (0.1,0.1) rectangle (2.9,2.9); 18 | \node[align=center] at (1.5,2.25) {Barefoot tracker\\ \scriptsize{(Java process)}}; 19 | \node[text width=2.6cm] at (1.65,1.0) {\scriptsize{\begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt,parsep=0pt,partopsep=0pt,listparindent=0pt,itemindent=0pt,leftmargin=0pt,labelsep=2pt] 20 | \item{Map matches object position messages in real-time} 21 | \item{Maintains states of moving objects} 22 | \end{itemize}} 23 | }; 24 | 25 | \draw[-latex,thick] (3.2,1.5) to node[above,midway] {ZeroMQ} (4.8,1.5); 26 | 27 | % Monitor server 28 | \draw[thick,rounded corners,fill={rgb:red,0;green,51;blue,102},opacity=0.3] (5.1,0.1) rectangle (7.9,2.9); 29 | \node[align=center] at (6.5,2.25) {Monitor backend\\ \scriptsize{(NodeJS server)}}; 30 | \node[text width=2.6cm] at (6.65,1.0) {\scriptsize{\begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt,parsep=0pt,partopsep=0pt,listparindent=0pt,itemindent=0pt,leftmargin=0pt,labelsep=2pt] 31 | \item{Buffers moving objects' states} 32 | \item{Server (Express) for web-based real-time visualization} 33 | \end{itemize}} 34 | }; 35 | 36 | \draw[-latex,thick] (8.2,1.5) to node[above,midway] {Socket.io} (9.8,1.5); 37 | 38 | % Browser 39 | \draw[thick,rounded corners,fill={rgb:red,102;green,0;blue,51},opacity=0.3] (10.1,0.1) rectangle (12.9,2.9); 40 | \node[align=center] at (11.5,2.25) {Monitor frontend\\ \scriptsize{(JavaScript website)}}; 41 | \node[text width=2.6cm] at (11.65,1.0) {\scriptsize{\begin{itemize}[itemsep=0pt,partopsep=0pt,topsep=0pt,parsep=0pt,partopsep=0pt,listparindent=0pt,itemindent=0pt,leftmargin=0pt,labelsep=2pt] 42 | \item{Shows objects' states on the map (OpenLayers) in real-time with positions and paths} 43 | \end{itemize}} 44 | }; 45 | \end{tikzpicture} 46 | \end{document} 47 | -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-scalable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/tracker-scalable.pdf -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-scalable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmwcarit/barefoot/97f1c03e5df96ef2571f8af443fc6dc39e8b217d/doc-files/com/bmwcarit/barefoot/tracker/tracker-scalable.png -------------------------------------------------------------------------------- /doc-files/com/bmwcarit/barefoot/tracker/tracker-scalable.tex: -------------------------------------------------------------------------------- 1 | \documentclass{standalone} 2 | \usepackage{enumitem} 3 | \usepackage{tikz} % Required for drawings 4 | \usetikzlibrary{shapes} 5 | \usetikzlibrary{calc} 6 | 7 | \begin{document} 8 | \definecolor{globegreen}{RGB}{61,184,82} 9 | \definecolor{whaleblue}{RGB}{37,184,235} 10 | 11 | \tikzstyle{node}=[draw,thick,rounded corners,opacity=0.3,inner sep=0pt,minimum width=1cm,minimum height=1cm,text opacity=1] 12 | \tikzstyle{kafka}=[node,fill=blue] 13 | \tikzstyle{storm}=[node,fill={rgb:red,25;green,51;blue,0}] 14 | \tikzstyle{cassandra}=[node,fill=yellow] 15 | \tikzstyle{monitor}=[node,fill={rgb:red,0;green,51;blue,102}] 16 | 17 | \begin{tikzpicture}[font=\sffamily] 18 | \node at (0,6) {Kafka}; 19 | 20 | \node[kafka] (k1) at (0,1.25) {}; 21 | \node[kafka] (k2) at (0,2.75) {}; 22 | \node[kafka] (k3) at (0,4.25) {}; 23 | 24 | \node at (2,6) {Storm}; 25 | 26 | \node[storm] (s1) at (2,0.5) {D}; 27 | \node[storm] (s2) at (2,2) {C}; 28 | \node[storm] (s3) at (2,3.5) {B}; 29 | \node[storm] (s4) at (2,5) {A}; 30 | 31 | \node at (4,6) {Cassandra}; 32 | 33 | \node[cassandra] (c1) at (4,1.25) {}; 34 | \node[cassandra] (c2) at (4,2.75) {}; 35 | \node[cassandra] (c3) at (4,4.25) {}; 36 | 37 | % \foreach \s in {1,2,3,4} { 38 | % \foreach \ck in {1,2,3} { 39 | % \draw[-latex,gray] (k\ck) -- (s\s); 40 | % \draw[-latex,gray] (s\s) -- (c\ck); 41 | % } 42 | % } 43 | 44 | \draw[-latex,very thick,blue,opacity=0.6] (0.6,2.75) -- (1.4,2.75); 45 | 46 | \draw[-latex,very thick,red,opacity=0.6] (2.6,3) -- (3.4,3); 47 | \draw[latex-,very thick,red,dashed,opacity=0.6] (2.6,2.5) -- (3.4,2.5); 48 | 49 | \path[-latex,dashed,very thick,blue,opacity=0.6,shorten >=10pt,shorten <=10pt] (s1.center) edge [bend left=12] (s4.center); 50 | \path[-latex,dashed,very thick,blue,opacity=0.6,shorten >=10pt,shorten <=10pt] (s4.center) edge [bend left=12] (s1.center); 51 | 52 | \draw[-,opacity=0] (-4,0) rectangle (9,5); 53 | \end{tikzpicture} 54 | \end{document} 55 | -------------------------------------------------------------------------------- /map/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015, BMW Car IT GmbH 3 | # 4 | # Author: Sebastian Mattheis 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | # in compliance with the License. You may obtain a copy of the License at 8 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | # language governing permissions and limitations under the License. 12 | # 13 | 14 | FROM ubuntu:14.04 15 | 16 | MAINTAINER sebastian.mattheis@bmw-carit.de 17 | 18 | ADD /pgsql/ /opt/pgsql/ 19 | RUN apt-get update && apt-get -y install patch postgresql-9.3-postgis-2.1 git openjdk-7-jdk python-psycopg2 python-numpy python-gdal 20 | RUN patch /etc/postgresql/9.3/main/postgresql.conf < /opt/pgsql/postgresql.conf.patch && patch /etc/postgresql/9.3/main/pg_hba.conf < /opt/pgsql/pg_hba.conf.patch && echo "export HOME=/root" >> /root/.bashrc 21 | RUN cd /opt/ && git clone https://github.com/openstreetmap/osmosis.git && cd osmosis && git checkout tags/0.43.1 && ./gradlew assemble && echo "export PATH=${PATH}:/opt/osmosis/package/bin" >> /root/.bashrc 22 | CMD service postgresql start && /bin/bash --rcfile /root/.bashrc 23 | -------------------------------------------------------------------------------- /map/osm/import.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2015, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | set -o errexit -o nounset 17 | 18 | if [ "$#" -eq "6" ] && ( [ "$6" = "slim" ] || [ "$6" = "normal" ] ) 19 | then 20 | input=$1 21 | database=$2 22 | user=$3 23 | password=$4 24 | config=$5 25 | mode=$6 26 | elif [ "$#" -eq "0" ] 27 | then 28 | input=/mnt/map/osm/oberbayern.osm.pbf 29 | database=oberbayern 30 | user=osmuser 31 | password=pass 32 | config=/mnt/map/tools/road-types.json 33 | mode=slim 34 | else 35 | echo "Error. Say '$0 osm-file database user password bfmap-config slim|normal' or run with defaults '$0'." 36 | exit 37 | fi 38 | 39 | echo "Start creation and initialization of database '${database}' ..." 40 | sudo -u postgres createdb ${database} || true 41 | sudo -u postgres psql -d ${database} -c "CREATE EXTENSION hstore;" || true 42 | sudo -u postgres psql -d ${database} -c "CREATE EXTENSION postgis;" || true 43 | echo "Done." 44 | 45 | echo "Start creation of user and initialization of credentials ..." 46 | sudo -u postgres psql -c "CREATE USER \"${user}\" PASSWORD '${password}';" || true 47 | sudo -u postgres psql -c "GRANT ALL ON DATABASE \"${database}\" TO \"${user}\";" 48 | passphrase="localhost:5432:${database}:${user}:${password}" 49 | if [ ! -e ~/.pgpass ] || [ `cat ~/.pgpass | grep -c "$passphrase"` -eq 0 ] 50 | then 51 | echo "$passphrase" >> ~/.pgpass 52 | chmod 0600 ~/.pgpass 53 | fi 54 | echo "Done." 55 | 56 | echo "Start population of OSM data (osmosis) ..." 57 | psql -h localhost -d ${database} -U ${user} -f /mnt/map/osm/pgsnapshot_schema_0.6.sql 58 | rm -rf /mnt/map/osm/tmp 59 | mkdir /mnt/map/osm/tmp 60 | if [ -z "${JAVACMD_OPTIONS:-}" ]; then 61 | JAVACMD_OPTIONS="-Djava.io.tmpdir=/mnt/map/osm/tmp" 62 | else 63 | JAVACMD_OPTIONS="$JAVACMD_OPTIONS -Djava.io.tmpdir=/mnt/map/osm/tmp" 64 | fi 65 | export JAVACMD_OPTIONS 66 | osmosis --read-pbf file=${input} --tf accept-ways highway=* --write-pgsql user="${user}" password="${password}" database="${database}" 67 | echo "Done." 68 | 69 | echo "Start extraction of routing data (bfmap tools) ..." 70 | cd /mnt/map/tools/ 71 | if [ "$mode" = "slim" ] 72 | then 73 | python osm2ways.py --host localhost --port 5432 --database ${database} --table temp_ways --user ${user} --password ${password} --slim 74 | elif [ "$mode" = "normal" ] 75 | then 76 | python osm2ways.py --host localhost --port 5432 --database ${database} --table temp_ways --user ${user} --password ${password} --prefix _tmp 77 | fi 78 | python ways2bfmap.py --source-host localhost --source-port 5432 --source-database ${database} --source-table temp_ways --source-user ${user} --source-password ${password} --target-host localhost --target-port 5432 --target-database ${database} --target-table bfmap_ways --target-user ${user} --target-password ${password} --config ${config} 79 | echo "Done." 80 | -------------------------------------------------------------------------------- /map/pgsql/pg_hba.conf.patch: -------------------------------------------------------------------------------- 1 | --- /etc/postgresql/9.3/main/pg_hba.conf.original 2014-10-25 19:55:37.469260394 +0000 2 | +++ /etc/postgresql/9.3/main/pg_hba.conf 2014-10-25 20:13:38.676594184 +0000 3 | @@ -97,3 +97,4 @@ 4 | #local replication postgres peer 5 | #host replication postgres 127.0.0.1/32 md5 6 | #host replication postgres ::1/128 md5 7 | +host all all samenet md5 8 | 9 | -------------------------------------------------------------------------------- /map/pgsql/postgresql.conf.patch: -------------------------------------------------------------------------------- 1 | --- /etc/postgresql/9.3/main/postgresql.conf.original 2014-10-25 19:55:37.478260085 +0000 2 | +++ /etc/postgresql/9.3/main/postgresql.conf 2014-10-25 20:12:12.215516083 +0000 3 | @@ -56,7 +56,7 @@ 4 | 5 | # - Connection Settings - 6 | 7 | -#listen_addresses = 'localhost' # what IP address(es) to listen on; 8 | +listen_addresses = '*' # what IP address(es) to listen on; 9 | # comma-separated list of addresses; 10 | # defaults to 'localhost'; use '*' for all 11 | # (change requires restart) 12 | 13 | -------------------------------------------------------------------------------- /map/samples/import.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2015, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | if [ "$#" -eq "4" ] 17 | then 18 | input=$1 19 | database=$2 20 | user=$3 21 | password=$4 22 | elif [ "$#" -eq "0" ] 23 | then 24 | input=/mnt/map/samples/x0001-015.sql 25 | database=samples 26 | user=sampleuser 27 | password=pass 28 | else 29 | echo "Error. Say '$0 sql-file database user password' or run with defaults '$0'." 30 | exit 31 | fi 32 | 33 | echo "Start creation and initialization of database '${database}' ..." 34 | sudo -u postgres createdb ${database} 35 | sudo -u postgres psql -d ${database} -c "CREATE EXTENSION hstore;" 36 | sudo -u postgres psql -d ${database} -c "CREATE EXTENSION postgis;" 37 | echo "Done." 38 | 39 | echo "Start creation of user and initialization of credentials ..." 40 | sudo -u postgres psql -c "CREATE USER ${user} PASSWORD '${password}';" 41 | sudo -u postgres psql -c "GRANT ALL ON DATABASE ${database} TO ${user};" 42 | passphrase="localhost:5432:${database}:${user}:${password}" 43 | if [ ! -e ~/.pgpass ] || [ `less ~/.pgpass | grep -c "$passphrase"` -eq 0 ] 44 | then 45 | echo "$passphrase" >> ~/.pgpass 46 | chmod 0600 ~/.pgpass 47 | fi 48 | echo "Done." 49 | 50 | echo "Start population of sample data ..." 51 | psql -h localhost -d ${database} -U ${user} -f ${input} 52 | echo "Done." 53 | -------------------------------------------------------------------------------- /map/tools/road-types.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": 3 | [ 4 | { 5 | "tag":"highway","id":1,"values": 6 | [ 7 | { 8 | "name":"motorway", 9 | "id":101, 10 | "priority":0.9, 11 | "maxspeed":130 12 | }, 13 | { 14 | "name":"motorway_link", 15 | "id":102, 16 | "priority":1.1, 17 | "maxspeed":80 18 | }, 19 | { 20 | "name":"motorway_junction", 21 | "id":103, 22 | "priority":1.1, 23 | "maxspeed":80 24 | }, 25 | { 26 | "name":"trunk", 27 | "id":104, 28 | "priority":1.1, 29 | "maxspeed":120 30 | }, 31 | { 32 | "name":"trunk_link", 33 | "id":105, 34 | "priority":1.2, 35 | "maxspeed":80 36 | }, 37 | { 38 | "name":"primary", 39 | "id":106, 40 | "priority":1.2, 41 | "maxspeed":110 42 | }, 43 | { 44 | "name":"primary_link", 45 | "id":107, 46 | "priority":1.3, 47 | "maxspeed":80 48 | }, 49 | { 50 | "name":"secondary", 51 | "id":108, 52 | "priority":1.4, 53 | "maxspeed":80 54 | }, 55 | { 56 | "name":"secondary_link", 57 | "id":109, 58 | "priority":1.5, 59 | "maxspeed":60 60 | }, 61 | { 62 | "name":"tertiary", 63 | "id":110, 64 | "priority":1.6, 65 | "maxspeed":60 66 | }, 67 | { 68 | "name":"tertiary_link", 69 | "id":111, 70 | "priority":1.7, 71 | "maxspeed":40 72 | }, 73 | { 74 | "name":"residential", 75 | "id":112, 76 | "priority":2.5, 77 | "maxspeed":50 78 | }, 79 | { 80 | "name":"living_street", 81 | "id":113, 82 | "priority":3, 83 | "maxspeed":20 84 | }, 85 | { 86 | "name":"service", 87 | "id":114, 88 | "priority":5, 89 | "maxspeed":50 90 | }, 91 | { 92 | "name":"road", 93 | "id":115, 94 | "priority":5, 95 | "maxspeed":50 96 | }, 97 | { 98 | "name":"unclassified", 99 | "id":117, 100 | "priority":3, 101 | "maxspeed":50 102 | } 103 | ] 104 | } 105 | ] 106 | } -------------------------------------------------------------------------------- /map/tools/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2015, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | set -o errexit -o nounset 17 | 18 | . /mnt/map/tools/test/test.properties 19 | export PYTHONPATH=/mnt/map/tools/ 20 | cd /mnt/map/tools/test 21 | 22 | echo "Create ${database} database ..." 23 | sudo -u postgres psql -q -c "CREATE DATABASE ${database};" 24 | function cleanup { 25 | echo "Delete ${database} database ..." 26 | sudo -u postgres psql -q -c "DROP DATABASE ${database};" 27 | sudo -u postgres psql -q -c "DROP USER IF EXISTS ${user};" 28 | echo "Done." 29 | } 30 | trap cleanup EXIT 31 | sudo -u postgres psql -q -d ${database} -c "CREATE EXTENSION hstore;" 32 | sudo -u postgres psql -q -d ${database} -c "CREATE EXTENSION postgis;" 33 | sudo -u postgres psql -q -c "CREATE USER ${user} PASSWORD '${password}';" 34 | sudo -u postgres psql -q -c "GRANT ALL ON DATABASE ${database} TO ${user};" 35 | 36 | echo "Run bfmap test ..." 37 | sudo -u postgres psql -q -d ${database} -f /mnt/map/tools/test/${bfmap_table} 38 | sudo -u postgres psql -q -d ${database} -c "GRANT ALL ON TABLE temp_ways TO ${user};" 39 | python -m unittest test_bfmap 40 | -------------------------------------------------------------------------------- /map/tools/test/test-types.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": 3 | [ 4 | { 5 | "tag":"highway","id":1,"values": 6 | [ 7 | { 8 | "name":"motorway", 9 | "id":101, 10 | "priority":1.0, 11 | "maxspeed":130 12 | }, 13 | { 14 | "name":"motorway_link", 15 | "id":102, 16 | "priority":1.0, 17 | "maxspeed":130 18 | }, 19 | { 20 | "name":"motorway_junction", 21 | "id":103, 22 | "priority":1.0, 23 | "maxspeed":130 24 | }, 25 | { 26 | "name":"trunk", 27 | "id":104, 28 | "priority":1.05, 29 | "maxspeed":110 30 | }, 31 | { 32 | "name":"trunk_link", 33 | "id":105, 34 | "priority":1.05, 35 | "maxspeed":110 36 | }, 37 | { 38 | "name":"primary", 39 | "id":106, 40 | "priority":1.15, 41 | "maxspeed":90 42 | }, 43 | { 44 | "name":"primary_link", 45 | "id":107, 46 | "priority":1.15, 47 | "maxspeed":90 48 | }, 49 | { 50 | "name":"secondary", 51 | "id":108, 52 | "priority":1.5, 53 | "maxspeed":90 54 | }, 55 | { 56 | "name":"secondary_link", 57 | "id":109, 58 | "priority":1.5, 59 | "maxspeed":90 60 | }, 61 | { 62 | "name":"tertiary", 63 | "id":110, 64 | "priority":1.75, 65 | "maxspeed":90 66 | }, 67 | { 68 | "name":"tertiary_link", 69 | "id":111, 70 | "priority":1.75, 71 | "maxspeed":90 72 | } 73 | ] 74 | }, 75 | { 76 | "tag":"railway","id":2,"values": 77 | [ 78 | { 79 | "name":"rail", 80 | "id":201, 81 | "priority":1.0, 82 | "maxspeed":200 83 | }, 84 | { 85 | "name":"subway", 86 | "id":202, 87 | "priority":1.0, 88 | "maxspeed":60 89 | }, 90 | { 91 | "name":"tram", 92 | "id":203, 93 | "priority":1.0, 94 | "maxspeed":40 95 | }, 96 | { 97 | "name":"light_rail", 98 | "id":204, 99 | "priority":2.0, 100 | "maxspeed":40 101 | } 102 | ] 103 | } 104 | ] 105 | } 106 | -------------------------------------------------------------------------------- /map/tools/test/test.properties: -------------------------------------------------------------------------------- 1 | database=test 2 | user=testuser 3 | password=pass 4 | bfmap_table=test_bfmap.sql 5 | config=/mnt/map/tools/road-types.json -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/analysis/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Set of machine learning functions for (mainly spatial or density-based) cluster analysis. 16 | */ 17 | package com.bmwcarit.barefoot.analysis; 18 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/markov/Factory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.markov; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | /** 20 | * Factory for creation of state candidates, which is {@link StateCandidate}, transitions, which is 21 | * {@link StateTransition}, and samples, i.e. {@link Sample}. A {@link Factory} instance enables 22 | * dependency injection during creation from their respective JSON representation. 23 | * 24 | * @param Candidate inherits from {@link StateCandidate}. 25 | * @param Transition inherits from {@link StateTransition}. 26 | * @param Sample inherits from {@link Sample}. 27 | */ 28 | public abstract class Factory, T extends StateTransition, S extends Sample> { 29 | 30 | /** 31 | * Creates an {@link StateCandidate} object. 32 | * 33 | * @param json JSON representation of an {@link StateCandidate} object. 34 | * @return {@link StateCandidate} object. 35 | * @throws JSONException thrown on JSON extraction or parsing error. 36 | */ 37 | public abstract C candidate(JSONObject json) throws JSONException; 38 | 39 | /** 40 | * Creates a {@link StateTransition} object. 41 | * 42 | * @param json JSON representation of a {@link StateTransition} object. 43 | * @return {@link StateTransition} object. 44 | * @throws JSONException thrown on JSON extraction or parsing error. 45 | */ 46 | public abstract T transition(JSONObject json) throws JSONException; 47 | 48 | /** 49 | * Creates a {@link Sample} object. 50 | * 51 | * @param json JSON representation of a {@link Sample} object. 52 | * @return {@link Sample} object. 53 | * @throws JSONException thrown on JSON extraction or parsing error. 54 | */ 55 | public abstract S sample(JSONObject json) throws JSONException; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/markov/Sample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.markov; 14 | 15 | import java.text.ParseException; 16 | import java.text.SimpleDateFormat; 17 | 18 | import org.json.JSONException; 19 | import org.json.JSONObject; 20 | 21 | /** 22 | * Measurement sample as input for Hidden Markov Model (HMM) inference, e.g. with a HMM filter 23 | * {@link Filter}. 24 | */ 25 | public class Sample { 26 | private long time; 27 | 28 | /** 29 | * Creates {@link Sample} object with a timestamp in milliseconds epoch time. 30 | * 31 | * @param time Timestamp of position measurement in milliseconds epoch time. 32 | */ 33 | public Sample(long time) { 34 | this.time = time; 35 | } 36 | 37 | /** 38 | * Creates {@link Sample} object from JSON representation. 39 | * 40 | * @param json JSON representation of a sample. 41 | * @throws JSONException thrown on JSON extraction or parsing error. 42 | */ 43 | public Sample(JSONObject json) throws JSONException { 44 | time = json.optLong("time", Long.MIN_VALUE); 45 | if (time == Long.MIN_VALUE) { 46 | String string = json.optString("time", ""); 47 | if (!string.isEmpty()) { 48 | try { 49 | time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssX") 50 | .parse(json.getString("time")).getTime(); 51 | } catch (ParseException e) { 52 | throw new JSONException(e); 53 | } 54 | } else { 55 | throw new JSONException("time key not found"); 56 | } 57 | } 58 | } 59 | 60 | /** 61 | * Gets the timestamp of the measurement sample in milliseconds epoch time. 62 | * 63 | * @return Timestamp of the measurement in milliseconds epoch time. 64 | */ 65 | public long time() { 66 | return time; 67 | } 68 | 69 | /** 70 | * Gets a JSON representation of the {@link Sample} object. 71 | * 72 | * @return JSON representation of the {@link Sample} object. 73 | * @throws JSONException thrown on JSON extraction or parsing error. 74 | */ 75 | public JSONObject toJSON() throws JSONException { 76 | JSONObject json = new JSONObject(); 77 | json.put("time", time); 78 | return json; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/markov/StateTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.markov; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | /** 20 | * Transition between state candidates, i.e. {@link StateCandidate} objects. 21 | */ 22 | public class StateTransition { 23 | 24 | /** 25 | * Creates {@link StateTransition} object. 26 | */ 27 | public StateTransition() { 28 | return; 29 | } 30 | 31 | /** 32 | * Creates {@link StateTransition} object from JSON representation. 33 | * 34 | * @param json JSON representation of a transition. 35 | * @throws JSONException thrown on JSON extraction or parsing error. 36 | */ 37 | public StateTransition(JSONObject json) throws JSONException { 38 | return; 39 | } 40 | 41 | /** 42 | * Gets a JSON representation of the {@link StateTransition} object. 43 | * 44 | * @return JSON representation of the {@link StateTransition} object. 45 | * @throws JSONException thrown on JSON extraction or parsing error. 46 | */ 47 | public JSONObject toJSON() throws JSONException { 48 | return new JSONObject(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/markov/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Hidden Markov Model (HMM) implementation with HMM filter and state memory for supporting online 16 | * Viterbi algorithm. 17 | */ 18 | package com.bmwcarit.barefoot.markov; 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/matcher/MatcherCandidate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.matcher; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | import com.bmwcarit.barefoot.markov.StateCandidate; 20 | import com.bmwcarit.barefoot.roadmap.RoadMap; 21 | import com.bmwcarit.barefoot.roadmap.RoadPoint; 22 | 23 | /** 24 | * Matching candidate for Hidden Markov Model (HMM) map matching representing a position on the map. 25 | */ 26 | public class MatcherCandidate 27 | extends StateCandidate { 28 | private final RoadPoint point; 29 | 30 | /** 31 | * Creates a matching candidate. 32 | * 33 | * @param point {@link RoadPoint} object that is point on the map represented by matching 34 | * candidate. 35 | */ 36 | public MatcherCandidate(RoadPoint point) { 37 | this.point = point; 38 | } 39 | 40 | /** 41 | * Creates a matching candidate from its JSON representation. 42 | * 43 | * @param json JSON representation of matching candidate. 44 | * @param factory Matcher factory for creation of matching candidates, transitions and samples. 45 | * @param map {@link RoadMap} object used for creation of matching candidates, transitions and 46 | * samples. 47 | * @throws JSONException thrown on JSON parse error. 48 | */ 49 | public MatcherCandidate(JSONObject json, MatcherFactory factory, RoadMap map) 50 | throws JSONException { 51 | super(json, factory); 52 | point = RoadPoint.fromJSON(json.getJSONObject("point"), map); 53 | } 54 | 55 | /** 56 | * Gets {@link RoadPoint} as point on the map represented by the matching candidate. 57 | * 58 | * @return {@link RoadPoint} object of the matching candidate. 59 | */ 60 | public RoadPoint point() { 61 | return point; 62 | } 63 | 64 | @Override 65 | public JSONObject toJSON() throws JSONException { 66 | JSONObject json = super.toJSON(); 67 | json.put("point", point.toJSON()); 68 | return json; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/matcher/MatcherFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.matcher; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | import com.bmwcarit.barefoot.markov.Factory; 20 | import com.bmwcarit.barefoot.roadmap.RoadMap; 21 | 22 | /** 23 | * Matcher factory for creation of matching candidates, transitions, and samples. 24 | */ 25 | public class MatcherFactory extends Factory { 26 | private final RoadMap map; 27 | 28 | /** 29 | * Creates {@link MatcherFactory} object. 30 | * 31 | * @param map {@link RoadMap} object used for creation of matching candidates, transitions and 32 | * samples. 33 | */ 34 | public MatcherFactory(RoadMap map) { 35 | this.map = map; 36 | } 37 | 38 | @Override 39 | public MatcherCandidate candidate(JSONObject json) throws JSONException { 40 | return new MatcherCandidate(json, this, map); 41 | } 42 | 43 | @Override 44 | public MatcherTransition transition(JSONObject json) throws JSONException { 45 | return new MatcherTransition(json, map); 46 | } 47 | 48 | @Override 49 | public MatcherSample sample(JSONObject json) throws JSONException { 50 | return new MatcherSample(json); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/matcher/MatcherTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.matcher; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | import com.bmwcarit.barefoot.markov.StateTransition; 20 | import com.bmwcarit.barefoot.roadmap.RoadMap; 21 | import com.bmwcarit.barefoot.roadmap.Route; 22 | 23 | /** 24 | * State transition between matching candidates in Hidden Markov Model (HMM) map matching and 25 | * contains a route between respective map positions. 26 | */ 27 | public class MatcherTransition extends StateTransition { 28 | private Route route = null; 29 | 30 | /** 31 | * Creates {@link MatcherTransition} object. 32 | * 33 | * @param route {@link Route} object as state transition in map matching. 34 | */ 35 | public MatcherTransition(Route route) { 36 | this.route = route; 37 | } 38 | 39 | /** 40 | * Creates {@link MatcherTransition} object from its JSON representation. 41 | * 42 | * @param json JSON representation of {@link MatcherTransition} object. 43 | * @param map {@link RoadMap} object 44 | * @throws JSONException thrown on JSON parse error. 45 | */ 46 | public MatcherTransition(JSONObject json, RoadMap map) throws JSONException { 47 | super(json); 48 | route = Route.fromJSON(json.getJSONObject("route"), map); 49 | } 50 | 51 | /** 52 | * Gets {@link Route} object of the state transition. 53 | * 54 | * @return {@link Route} object of the state transition. 55 | */ 56 | public Route route() { 57 | return route; 58 | } 59 | 60 | @Override 61 | public JSONObject toJSON() throws JSONException { 62 | JSONObject json = super.toJSON(); 63 | json.put("route", route.toJSON()); 64 | return json; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/matcher/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Hidden Markov Model (HMM) map matching to determine an object's path (online or offline) and an 16 | * object's current position (online) on the map. 17 | */ 18 | package com.bmwcarit.barefoot.matcher; 19 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/BfmapReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | import java.io.FileInputStream; 17 | import java.io.FileNotFoundException; 18 | import java.io.IOException; 19 | import java.io.ObjectInput; 20 | import java.io.ObjectInputStream; 21 | import java.util.HashSet; 22 | 23 | import com.bmwcarit.barefoot.util.SourceException; 24 | import com.esri.core.geometry.GeometryEngine; 25 | import com.esri.core.geometry.Polygon; 26 | import com.esri.core.geometry.SpatialReference; 27 | 28 | /** 29 | * Barefoot map road reader for reading {@link BaseRoad} object from barefoot map files, usually 30 | * with file extension 'bfmap'. 31 | */ 32 | public class BfmapReader implements RoadReader { 33 | 34 | private final String path; 35 | private ObjectInput reader = null; 36 | private HashSet exclusions = null; 37 | private Polygon polygon = null; 38 | 39 | /** 40 | * Constructs a {@link BfmapReader} object reading from a file. 41 | * 42 | * @param path Path to barefoot map file to be read. 43 | */ 44 | public BfmapReader(String path) { 45 | this.path = path; 46 | } 47 | 48 | @Override 49 | public boolean isOpen() { 50 | if (reader != null) { 51 | return true; 52 | } else { 53 | return false; 54 | } 55 | } 56 | 57 | @Override 58 | public void open() throws SourceException { 59 | open(null, null); 60 | } 61 | 62 | @Override 63 | public void open(Polygon polygon, HashSet exclusions) throws SourceException { 64 | try { 65 | this.reader = new ObjectInputStream(new FileInputStream(path)); 66 | this.exclusions = exclusions; 67 | this.polygon = polygon; 68 | } catch (FileNotFoundException e) { 69 | throw new SourceException("File could not be found for path: " + path); 70 | } catch (IOException e) { 71 | throw new SourceException("Opening reader failed: " + e.getMessage()); 72 | } 73 | } 74 | 75 | @Override 76 | public void close() throws SourceException { 77 | try { 78 | reader.close(); 79 | } catch (IOException e) { 80 | throw new SourceException("Closing file failed."); 81 | } 82 | } 83 | 84 | @Override 85 | public BaseRoad next() throws SourceException { 86 | if (!isOpen()) { 87 | throw new SourceException("File is closed or invalid."); 88 | } 89 | 90 | try { 91 | BaseRoad road = null; 92 | do { 93 | road = (BaseRoad) reader.readObject(); 94 | if (road == null) { 95 | return null; 96 | } 97 | } while (exclusions != null && exclusions.contains(road.type()) || polygon != null 98 | && !GeometryEngine.contains(polygon, road.geometry(), 99 | SpatialReference.create(4326)) 100 | && !GeometryEngine.overlaps(polygon, road.geometry(), 101 | SpatialReference.create(4326))); 102 | 103 | return road; 104 | } catch (ClassNotFoundException e) { 105 | throw new SourceException("File is corrupted, read object is not a road."); 106 | } catch (IOException e) { 107 | throw new SourceException("Reading file failed: " + e.getMessage()); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/BfmapWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | import java.io.FileNotFoundException; 17 | import java.io.FileOutputStream; 18 | import java.io.IOException; 19 | import java.io.ObjectOutput; 20 | import java.io.ObjectOutputStream; 21 | 22 | import com.bmwcarit.barefoot.util.SourceException; 23 | 24 | /** 25 | * Barefoot map road writer for writing {@link BaseRoad} to barefoot map files, usually with file 26 | * extension 'bfmap'. 27 | */ 28 | public class BfmapWriter implements RoadWriter { 29 | private final String path; 30 | private ObjectOutput writer = null; 31 | 32 | /** 33 | * Constructs a {@link BfmapWriter} object writing to a file. 34 | *

35 | * Note: If the file exists, it will be overwritten. 36 | * 37 | * @param path Path to the barefoot map file to be written. 38 | */ 39 | public BfmapWriter(String path) { 40 | this.path = path; 41 | } 42 | 43 | @Override 44 | public boolean isOpen() { 45 | if (writer != null) { 46 | return true; 47 | } else { 48 | return false; 49 | } 50 | } 51 | 52 | @Override 53 | public void open() throws SourceException { 54 | try { 55 | writer = new ObjectOutputStream(new FileOutputStream(path)); 56 | } catch (FileNotFoundException e) { 57 | throw new SourceException("File could not be found."); 58 | } catch (IOException e) { 59 | throw new SourceException("Opening writer failed: " + e.getMessage()); 60 | } 61 | } 62 | 63 | @Override 64 | public void close() throws SourceException { 65 | try { 66 | writer.writeObject(null); 67 | writer.close(); 68 | writer = null; 69 | } catch (IOException e) { 70 | throw new SourceException("Closing writer failed: " + e.getMessage()); 71 | } 72 | } 73 | 74 | @Override 75 | public void write(BaseRoad road) throws SourceException { 76 | if (!isOpen()) { 77 | throw new SourceException("Writer is not open."); 78 | } 79 | 80 | try { 81 | writer.writeObject(road); 82 | } catch (IOException e) { 83 | throw new SourceException("Writing failed: " + e.getMessage()); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/Heading.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | /** 17 | * Heading of road movements, for example on {@link BaseRoad}. {@link Heading#forward} indicates a 18 | * heading from road's source to target and {@link Heading#backward} vice versa, respectively. 19 | */ 20 | public enum Heading { 21 | forward, backward 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/RoadReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | import java.util.HashSet; 17 | 18 | import com.bmwcarit.barefoot.util.SourceException; 19 | import com.esri.core.geometry.Polygon; 20 | 21 | /** 22 | * Interface for readers of {@link BaseRoad} objects from different sources which depends on 23 | * implementation. 24 | */ 25 | public interface RoadReader { 26 | 27 | /** 28 | * Checks if the reader is open to read. 29 | * 30 | * @return True if reader is open, false otherwise. 31 | */ 32 | boolean isOpen(); 33 | 34 | /** 35 | * Opens the reader. 36 | * 37 | * @throws SourceException thrown on error while opening the source. 38 | */ 39 | void open() throws SourceException; 40 | 41 | /** 42 | * Opens the reader and restricts reading of {@link BaseRoad} objects to spatially contained or 43 | * overlapping with a {@link Polygon} and to only certain road types (see 44 | * {@link BaseRoad#type()} ) that are not excluded. 45 | * 46 | * @param polygon Spatial restriction for reading with a certain {@link Polygon}. Must be null 47 | * to disallow spatial restriction. 48 | * @param exclusion Set of excluded road types. Must be null to disallow type exclusions. 49 | * @throws SourceException thrown on error while opening the source. 50 | */ 51 | void open(Polygon polygon, HashSet exclusion) throws SourceException; 52 | 53 | /** 54 | * Closes the reader. 55 | * 56 | * @throws SourceException thrown on error while closing the source. 57 | */ 58 | void close() throws SourceException; 59 | 60 | /** 61 | * Gets next {@link BaseRoad} object from the source. If all roads have been read, it returns 62 | * null. 63 | * 64 | * @return {@link BaseRoad} object, null if all roads have been read. 65 | * @throws SourceException thrown on error while reading from the source. 66 | */ 67 | BaseRoad next() throws SourceException; 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/RoadWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | import com.bmwcarit.barefoot.util.SourceException; 17 | 18 | /** 19 | * Interface for writers {@link BaseRoad} objects, for writing to different types of sources. 20 | */ 21 | public interface RoadWriter { 22 | 23 | /** 24 | * Checks if the writer is open to write. 25 | * 26 | * @return True if writer is open, false otherwise. 27 | */ 28 | public boolean isOpen(); 29 | 30 | /** 31 | * Opens the writer. 32 | * 33 | * @throws SourceException thrown on error while opening the source. 34 | */ 35 | public void open() throws SourceException; 36 | 37 | /** 38 | * Closes the writer. 39 | * 40 | * @throws SourceException thrown on error while closing the source. 41 | */ 42 | public void close() throws SourceException; 43 | 44 | /** 45 | * Writes {@link BaseRoad} object to source. 46 | * 47 | * @param road {@link BaseRoad} object to be written to source. 48 | * @throws SourceException thrown on error while writing to the source. 49 | */ 50 | public void write(BaseRoad road) throws SourceException; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/road/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Road data management including data structures and readers for reading road data from different 16 | * sources. 17 | */ 18 | package com.bmwcarit.barefoot.road; 19 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/roadmap/Distance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.roadmap; 14 | 15 | import com.bmwcarit.barefoot.topology.Cost; 16 | 17 | /** 18 | * Distance cost function for routing in {@link Road} networks. 19 | */ 20 | public class Distance extends Cost { 21 | /** 22 | * Gets traveling distance for passing the road. 23 | * 24 | * @return Distance in meters for passing the road. 25 | */ 26 | @Override 27 | public double cost(Road road) { 28 | return road.length(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/roadmap/RoadPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | 19 | import com.bmwcarit.barefoot.spatial.Geography; 20 | import com.bmwcarit.barefoot.spatial.SpatialOperator; 21 | import com.esri.core.geometry.Point; 22 | 23 | /** 24 | * Point on a {@link Road} defined by a reference to the {@link Road} and a fraction f, with 25 | * 0 ≤ f ≤ 1, which defines an exact position on the {@link Road}. 26 | */ 27 | public class RoadPoint extends com.bmwcarit.barefoot.topology.Point { 28 | private static final SpatialOperator spatial = new Geography(); 29 | private final Point geometry; 30 | private final double azimuth; 31 | 32 | /** 33 | * Creates a {@link RoadPoint}. 34 | * 35 | * @param road {@link Road} object of the point. 36 | * @param fraction Exact position on the {@link Road} defined as fraction f, with 0 37 | * ≤ f ≤ 1. 38 | */ 39 | public RoadPoint(Road road, double fraction) { 40 | super(road, fraction); 41 | this.geometry = spatial.interpolate(road.geometry(), fraction); 42 | this.azimuth = spatial.azimuth(road.geometry(), fraction); 43 | } 44 | 45 | /** 46 | * Gets the geometry of the point on the {@link Road}. 47 | * 48 | * @return Geometry of the point on the road. 49 | */ 50 | public Point geometry() { 51 | return geometry; 52 | } 53 | 54 | public double azimuth() { 55 | return azimuth; 56 | } 57 | 58 | /** 59 | * Gets the JSON representation of the {@link RoadPoint}. 60 | * 61 | * @return JSON representation of the {@link RoadPoint}. 62 | * @throws JSONException thrown on JSON extraction or parsing error. 63 | */ 64 | public JSONObject toJSON() throws JSONException { 65 | JSONObject json = edge().toJSON(); 66 | json.put("frac", fraction()); 67 | return json; 68 | } 69 | 70 | /** 71 | * Creates a {@link RoadPoint} object from its JSON representation. 72 | * 73 | * @param json JSON representation of the {@link RoadPoint} object. 74 | * @param map {@link RoadMap} as reference of the {@link RoadPoint}. 75 | * @return {@link RoadPoint} object. 76 | * @throws JSONException thrown on JSON extraction or parsing error. 77 | */ 78 | public static RoadPoint fromJSON(JSONObject json, RoadMap map) throws JSONException { 79 | Road road = Road.fromJSON(json, map); 80 | double fraction = json.getDouble("frac"); 81 | return new RoadPoint(road, fraction); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/roadmap/Time.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import com.bmwcarit.barefoot.topology.Cost; 17 | 18 | /** 19 | * Time cost function for routing in {@link Road} networks. 20 | */ 21 | public class Time extends Cost { 22 | private static final float heuristic_speed = 130; 23 | private static final Distance distance = new Distance(); 24 | 25 | /** 26 | * Gets traveling time for passing the road. 27 | * 28 | * @return Time in seconds for passing the road. 29 | */ 30 | @Override 31 | public double cost(Road road) { 32 | return (distance.cost(road) * 3.6 / Math.min(road.maxspeed(), heuristic_speed)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/roadmap/TimePriority.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import com.bmwcarit.barefoot.topology.Cost; 17 | 18 | /** 19 | * Time-priority cost function for routing in {@link Road} networks. 20 | */ 21 | public class TimePriority extends Cost { 22 | private static final double heuristic_priority = 1; 23 | private static final Time time = new Time(); 24 | 25 | /** 26 | * Gets time-priority cost for passing the road, i.e. traveling time multiplied with priority 27 | * cost factor. 28 | * 29 | * @return Time-priority cost for passing the road 30 | */ 31 | @Override 32 | public double cost(Road road) { 33 | return time.cost(road) * Math.max(heuristic_priority, road.priority()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/roadmap/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Road map implementation for support of routing (topological information) and spatial search 16 | * operations (geometrical information). 17 | */ 18 | package com.bmwcarit.barefoot.roadmap; 19 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/scheduler/Group.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.scheduler; 15 | 16 | import java.util.Queue; 17 | import java.util.concurrent.ConcurrentLinkedQueue; 18 | import java.util.concurrent.atomic.AtomicBoolean; 19 | import java.util.concurrent.atomic.AtomicInteger; 20 | import java.util.concurrent.locks.Condition; 21 | import java.util.concurrent.locks.Lock; 22 | import java.util.concurrent.locks.ReentrantLock; 23 | 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | public class Group { 28 | private final static Logger logger = LoggerFactory.getLogger(Group.class); 29 | private final Scheduler scheduler; 30 | final Queue exceptions = new ConcurrentLinkedQueue(); 31 | final Lock syncLock = new ReentrantLock(); 32 | final Condition syncCond = syncLock.newCondition(); 33 | final AtomicInteger syncTasks = new AtomicInteger(); 34 | final AtomicBoolean cancelled = new AtomicBoolean(false); 35 | 36 | Group(Scheduler scheduler) { 37 | this.scheduler = scheduler; 38 | } 39 | 40 | public void spawn(Task task) { 41 | if (cancelled.get()) { 42 | logger.debug("group {} cancelled, won't spawn task {}", this, task); 43 | return; 44 | } 45 | 46 | if (logger.isTraceEnabled()) { 47 | logger.trace("group {} spawns task {}", this, task); 48 | } 49 | 50 | task.group = this; 51 | syncTasks.getAndIncrement(); 52 | 53 | if (scheduler.availTasks.getAndIncrement() == 0) { 54 | scheduler.availLock.lock(); 55 | logger.trace("scheduler signals workers"); 56 | scheduler.availCond.signalAll(); 57 | scheduler.availLock.unlock(); 58 | } 59 | 60 | scheduler.queue.add(task); 61 | } 62 | 63 | public void cancel() { 64 | cancelled.set(true); 65 | } 66 | 67 | public boolean sync() { 68 | logger.trace("group {} waits for tasks", this); 69 | if (scheduler.workers.contains(Thread.currentThread())) { 70 | Worker worker = (Worker) Thread.currentThread(); 71 | 72 | logger.trace("group {} waits with worker {}", this, worker.workerid); 73 | worker.syncCount.getAndIncrement(); 74 | while (syncTasks.get() > 0) { 75 | worker.execute(); 76 | } 77 | worker.syncCount.getAndDecrement(); 78 | } else { 79 | syncLock.lock(); 80 | while (syncTasks.get() > 0) { 81 | try { 82 | logger.trace("group {} thread sleeping", this); 83 | syncCond.await(); 84 | logger.trace("group {} thread signaled", this); 85 | } catch (InterruptedException e) { 86 | logger.error("group {} sync interrupted, gets cancelled", this); 87 | cancel(); 88 | } 89 | } 90 | syncLock.unlock(); 91 | } 92 | logger.trace("group {} synchronized", this.toString()); 93 | 94 | return exceptions.isEmpty() && !cancelled.get(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/scheduler/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.scheduler; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Queue; 18 | import java.util.concurrent.ConcurrentLinkedQueue; 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | import java.util.concurrent.atomic.AtomicInteger; 21 | import java.util.concurrent.locks.Condition; 22 | import java.util.concurrent.locks.Lock; 23 | import java.util.concurrent.locks.ReentrantLock; 24 | 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | public class Scheduler { 29 | private final static Logger logger = LoggerFactory.getLogger(Scheduler.class); 30 | final ArrayList workers = new ArrayList(); 31 | final AtomicInteger workersup = new AtomicInteger(); 32 | final Queue queue = new ConcurrentLinkedQueue(); 33 | final AtomicInteger availTasks = new AtomicInteger(); 34 | final AtomicBoolean stop = new AtomicBoolean(); 35 | final Lock availLock = new ReentrantLock(); 36 | final Condition availCond = availLock.newCondition(); 37 | final long spintime; 38 | 39 | public Scheduler(int numWorkers) { 40 | this.spintime = (long) 1E9; 41 | start(numWorkers); 42 | } 43 | 44 | public Scheduler(int numWorkers, long spintime) { 45 | this.spintime = spintime; 46 | start(numWorkers); 47 | } 48 | 49 | private void start(int numWorkers) { 50 | this.availTasks.set(0); 51 | this.workersup.set(0); 52 | this.stop.set(false); 53 | 54 | for (int i = 0; i < numWorkers; ++i) { 55 | workers.add(new Worker(i, this)); 56 | } 57 | 58 | for (Worker worker : workers) { 59 | worker.setDaemon(true); 60 | worker.start(); 61 | } 62 | logger.trace("scheduler started with {} workers", numWorkers); 63 | } 64 | 65 | public Group group() { 66 | return new Group(this); 67 | } 68 | 69 | public void shutdown() { 70 | logger.trace("scheduler shutting donw"); 71 | availTasks.getAndIncrement(); 72 | stop.set(true); 73 | 74 | availLock.lock(); 75 | availCond.signalAll(); 76 | availLock.unlock(); 77 | } 78 | 79 | public Task self() { 80 | if (workers.contains(Thread.currentThread())) { 81 | Worker worker = (Worker) Thread.currentThread(); 82 | return worker.current; 83 | } else { 84 | return null; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/scheduler/StaticScheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.scheduler; 15 | 16 | public class StaticScheduler { 17 | private static Scheduler scheduler = new Scheduler(Runtime.getRuntime().availableProcessors()); 18 | 19 | static public class InlineScheduler { 20 | private final Group group; 21 | private final Task task; 22 | 23 | protected InlineScheduler(Group group) { 24 | this.group = group; 25 | this.task = null; 26 | } 27 | 28 | protected InlineScheduler(Task task) { 29 | this.group = null; 30 | this.task = task; 31 | } 32 | 33 | public void spawn(Task task) { 34 | if (this.task != null) { 35 | this.task.spawn(task); 36 | } else { 37 | this.group.spawn(task); 38 | } 39 | } 40 | 41 | public boolean sync() { 42 | if (this.task != null) { 43 | return task.sync(); 44 | } else { 45 | return group.sync(); 46 | } 47 | } 48 | } 49 | 50 | public static void reset(int numWorkers) { 51 | scheduler.shutdown(); 52 | scheduler = new Scheduler(numWorkers); 53 | } 54 | 55 | public static void reset(int numWorkers, long spintime) { 56 | scheduler.shutdown(); 57 | scheduler = new Scheduler(numWorkers, spintime); 58 | } 59 | 60 | public static InlineScheduler scheduler() { 61 | Task self = scheduler.self(); 62 | if (self != null) { 63 | return new InlineScheduler(self); 64 | } else { 65 | return new InlineScheduler(scheduler.group()); 66 | } 67 | } 68 | 69 | public static void stop() { 70 | scheduler.shutdown(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/spatial/SpatialIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.spatial; 15 | 16 | import java.util.Set; 17 | 18 | import com.esri.core.geometry.Point; 19 | 20 | /** 21 | * Interface of spatial index for searching objects by means of spatial properties. There may be 22 | * different implementations of this interface providing different underlying data structures for 23 | * efficient data access, e.g. Quad-tree (see {@link QuadTreeIndex}) or R-Tree (not implemented 24 | * yet). 25 | * 26 | * @param Result types depend on the implementation. 27 | */ 28 | public interface SpatialIndex { 29 | /** 30 | * Gets nearest object stored in the index, which may be nevertheless multiple results if they 31 | * have the same distance. 32 | * 33 | * @param c Point of reference for nearest search. 34 | * @return Result set of nearest object(s), may be multiple objects if they have the same 35 | * distance. 36 | */ 37 | Set nearest(Point c); 38 | 39 | /** 40 | * Gets objects stored in the index that are within a certain radius or overlap a certain 41 | * radius. 42 | * 43 | * @param c Center point for radius search. 44 | * @param r Radius in meters. 45 | * @return Result set of object(s) that are within a the given radius or overlap the radius. 46 | */ 47 | Set radius(Point c, double r); 48 | 49 | /** 50 | * Gets k nearest objects stored in the index. 51 | * 52 | * @param c Point of reference for nearest search. 53 | * @param k Number of objects to be searched. 54 | * @return Result set of nearest objects (exactly k objects). 55 | */ 56 | Set knearest(Point c, int k); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/spatial/Vector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Implementation of the net.sf.geographiclib.Vector class 16 | */ 17 | package com.bmwcarit.barefoot.spatial; 18 | 19 | /** 20 | * Vector in three-dimensional space. 21 | */ 22 | public class Vector { 23 | /** 24 | * Component in x dimension. 25 | */ 26 | public double x = Double.NaN; 27 | /** 28 | * Component in y dimension. 29 | */ 30 | public double y = Double.NaN; 31 | /** 32 | * Component in z dimension. 33 | */ 34 | public double z = Double.NaN; 35 | 36 | /** 37 | * Vector constructor. 38 | *

39 | * 40 | * @param x Component in x dimension. 41 | * @param y Component in y dimension. 42 | * @param z Component in z dimension. 43 | */ 44 | public Vector(double x, double y, double z) { 45 | this.x = x; 46 | this.y = y; 47 | this.z = z; 48 | } 49 | 50 | /** 51 | * Addition with a vector. 52 | *

53 | * 54 | * @param other Vector for addition. 55 | * @return Added {@link Vector} object. 56 | */ 57 | public Vector add(Vector other) { 58 | return new Vector(this.x + other.x, this.y + other.y, this.z + other.z); 59 | } 60 | 61 | /** 62 | * Multiplication with a scalar. 63 | *

64 | * 65 | * @param a Scalar multiplicator. 66 | * @return Scaled {@link Vector} object. 67 | */ 68 | public Vector multiply(double a) { 69 | return new Vector(this.x * a, this.y * a, this.z * a); 70 | } 71 | 72 | /** 73 | * Cross product with a vector. 74 | *

75 | * 76 | * @param other Vector for cross product. 77 | * @return {@link Vector} object as result of cross product. 78 | */ 79 | public Vector cross(Vector other) { 80 | return new Vector((y * other.z) - (z * other.y), (z * other.x) - (x * other.z), 81 | (x * other.y) - (y * other.x)); 82 | } 83 | 84 | /** 85 | * Dot product with a vector. 86 | *

87 | * 88 | * @param other Vector for dot product. 89 | * @return Scalar as result of dot product. 90 | */ 91 | public double dot(Vector other) { 92 | return this.x * other.x + this.y * other.y + this.z * other.z; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/spatial/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Spatial operator and spatial index implementations. 16 | */ 17 | package com.bmwcarit.barefoot.spatial; 18 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/topology/Cost.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.topology; 15 | 16 | /** 17 | * Abstract cost function to be used for routing algorithms implementing {@link Router}. 18 | * 19 | * @param Implementation of {@link AbstractEdge} in a directed {@link Graph}. 20 | */ 21 | public abstract class Cost> { 22 | /** 23 | * Abstract function to define a custom cost function for traversing an edge. 24 | * 25 | * @param edge {@link AbstractEdge} for which cost value shall be calculated. 26 | * @return Cost value for traversing the edge. 27 | */ 28 | public abstract double cost(E edge); 29 | 30 | /** 31 | * Calculates cost value for traversing a certain fraction of the edge. It is assumed that costs 32 | * increase linearly while traversing an edge. 33 | * 34 | * @param edge {@link AbstractEdge} for which cost value shall be calculated. 35 | * @param fraction Fraction of the edge to be traversed. 36 | * @return Cost value for traversing a certain fraction of the edge. 37 | */ 38 | public double cost(E edge, double fraction) { 39 | return cost(edge) * fraction; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/topology/Edge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.topology; 15 | 16 | 17 | /** 18 | * Simple implementation of {@link AbstractEdge}. 19 | */ 20 | public class Edge extends AbstractEdge { 21 | private static final long serialVersionUID = 1L; 22 | private final long id; 23 | private final long source; 24 | private final long target; 25 | 26 | /** 27 | * Creates an {@link Edge} object. 28 | * 29 | * @param id Edge identifier. 30 | * @param source Identifier of the edge's source vertex. 31 | * @param target Identifier of the edge's target vertex. 32 | */ 33 | public Edge(long id, long source, long target) { 34 | this.id = id; 35 | this.source = source; 36 | this.target = target; 37 | } 38 | 39 | @Override 40 | public long id() { 41 | return id; 42 | } 43 | 44 | @Override 45 | public long source() { 46 | return source; 47 | } 48 | 49 | @Override 50 | public long target() { 51 | return target; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/topology/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.topology; 15 | 16 | /** 17 | * Point in a directed {@link Graph} which is a point on an {@link AbstractEdge} with a fraction in 18 | * the interval [0,1] that defines the exact position as linear interpolation along the 19 | * {@link AbstractEdge} from its source to target. 20 | * 21 | * @param {@link AbstractEdge} type of the graph. 22 | */ 23 | public class Point> { 24 | private final E edge; 25 | private final double fraction; 26 | 27 | /** 28 | * Creates a {@link Point} object by reference to an {@link AbstractEdge} and an exact position 29 | * defined by a fraction. 30 | * 31 | * @param edge {@link AbstractEdge} of the point in the graph. 32 | * @param fraction Fraction that defines the exact position on the {@link AbstractEdge}. 33 | */ 34 | public Point(E edge, double fraction) { 35 | this.edge = edge; 36 | this.fraction = fraction; 37 | } 38 | 39 | /** 40 | * Gets the {@link AbstractEdge} of the point. 41 | * 42 | * @return {@link AbstractEdge} of the point. 43 | */ 44 | public E edge() { 45 | return edge; 46 | } 47 | 48 | /** 49 | * Gets the fraction of the point. 50 | * 51 | * @return Fraction of the point. 52 | */ 53 | public double fraction() { 54 | return fraction; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/topology/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Graph network/topology implementation with routing (Dijkstra). 16 | */ 17 | package com.bmwcarit.barefoot.topology; 18 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/tracker/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Tracker stand-online server for Hidden Markov Model (HMM) online map matching and push 16 | * communication to listeners. 17 | */ 18 | package com.bmwcarit.barefoot.tracker; 19 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/PostgresSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.sql.Connection; 17 | import java.sql.DriverManager; 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import java.sql.Statement; 21 | import java.util.Properties; 22 | 23 | /** 24 | * PostgreSQL source for connecting and querying a PostgreSQL databases. 25 | */ 26 | public class PostgresSource { 27 | private final String host; 28 | private final int port; 29 | private final String database; 30 | private final String user; 31 | private final String password; 32 | 33 | private Connection connection = null; 34 | 35 | /** 36 | * Creates a {@link PostgresSource} object. 37 | * 38 | * @param host Host name of the database server. 39 | * @param port Port of the database server. 40 | * @param database Name of the database. 41 | * @param user User for accessing the database. 42 | * @param password Password of the user. 43 | */ 44 | public PostgresSource(String host, int port, String database, String user, String password) { 45 | this.host = host; 46 | this.port = port; 47 | this.database = database; 48 | this.user = user; 49 | this.password = password; 50 | } 51 | 52 | /** 53 | * Checks if the database connection has been established. 54 | * 55 | * @return True if database connection is established, false otherwise. 56 | */ 57 | public boolean isOpen() { 58 | try { 59 | if (connection != null && connection.isValid(5)) { 60 | return true; 61 | } else { 62 | return false; 63 | } 64 | } catch (Exception e) { 65 | return false; 66 | } 67 | } 68 | 69 | /** 70 | * Connects to the database. 71 | * 72 | * @throws SourceException thrown if opening database connection failed. 73 | */ 74 | public void open() throws SourceException { 75 | try { 76 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 77 | Properties props = new Properties(); 78 | props.setProperty("user", user); 79 | props.setProperty("password", password); 80 | // props.setProperty("ssl","true"); 81 | connection = DriverManager.getConnection(url, props); 82 | connection.setAutoCommit(false); 83 | } catch (SQLException e) { 84 | throw new SourceException("Opening PostgreSQL connection failed: " + e.getMessage(), e); 85 | } 86 | } 87 | 88 | /** 89 | * Closes database connection. 90 | * 91 | * @throws SourceException thrown if closing database connection failed. 92 | */ 93 | public void close() throws SourceException { 94 | try { 95 | connection.close(); 96 | connection = null; 97 | } catch (SQLException e) { 98 | throw new SourceException("Closing PostgreSQL connection failed: " + e.getMessage(), e); 99 | } 100 | } 101 | 102 | /** 103 | * Executes a query that is specified as a query string. 104 | * 105 | * @param query Query string statement. 106 | * @return Result of the query as {@link ResultSet} object. 107 | * @throws SourceException thrown if execution of query failed. 108 | */ 109 | protected ResultSet execute(String query) throws SourceException { 110 | ResultSet query_result = null; 111 | 112 | if (!isOpen()) { 113 | throw new SourceException("PostgreSQL connection is closed or invalid."); 114 | } 115 | 116 | try { 117 | Statement statement = connection.createStatement(); 118 | statement.setFetchSize(100); 119 | query_result = statement.executeQuery(query); 120 | 121 | } catch (SQLException e) { 122 | throw new SourceException("Executing PostgreSQL query failed: " + e.getMessage(), e); 123 | } 124 | 125 | return query_result; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Quadruple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.io.Serializable; 17 | 18 | /** 19 | * Generic 4-tuple (quadruple). 20 | * 21 | * @param Type of first element. 22 | * @param Type of second element. 23 | * @param Type of third element. 24 | * @param Type of fourth element. 25 | */ 26 | public class Quadruple extends Triple implements Serializable { 27 | private static final long serialVersionUID = 1L; 28 | private D four = null; 29 | 30 | /** 31 | * Creates a {@link Quadruple} object. 32 | * 33 | * @param one First element. 34 | * @param two Second element. 35 | * @param three Third element. 36 | * @param four Fourth element. 37 | */ 38 | public Quadruple(A one, B two, C three, D four) { 39 | super(one, two, three); 40 | this.four = four; 41 | } 42 | 43 | /** 44 | * Gets fourth element. 45 | * 46 | * @return Fourth element, may be null if set to null previously. 47 | */ 48 | public D four() { 49 | return four; 50 | } 51 | 52 | /** 53 | * Sets fourth element. 54 | * 55 | * @param four Fourth element. 56 | */ 57 | public void four(D four) { 58 | this.four = four; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Quintuple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.io.Serializable; 17 | 18 | /** 19 | * Generic 5-tuple (quintuple). 20 | * 21 | * @param Type of first element. 22 | * @param Type of second element. 23 | * @param Type of third element. 24 | * @param Type of fourth element. 25 | * @param Type of fifth element. 26 | */ 27 | public class Quintuple extends Quadruple implements Serializable { 28 | private static final long serialVersionUID = 1L; 29 | private E five = null; 30 | 31 | /** 32 | * Creates a {@link Quintuple} object. 33 | * 34 | * @param one First element. 35 | * @param two Second element. 36 | * @param three Third element. 37 | * @param four Fourth element. 38 | * @param five Fifth element. 39 | */ 40 | public Quintuple(A one, B two, C three, D four, E five) { 41 | super(one, two, three, four); 42 | this.five = five; 43 | } 44 | 45 | /** 46 | * Gets fifth element. 47 | * 48 | * @return Fifth element, may be null if set to null previously. 49 | */ 50 | public E five() { 51 | return five; 52 | } 53 | 54 | /** 55 | * Sets fifth element. 56 | * 57 | * @param five Fifth element. 58 | */ 59 | public void five(E five) { 60 | this.five = five; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/SampleReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.util; 14 | 15 | import java.util.Date; 16 | 17 | import com.bmwcarit.barefoot.matcher.MatcherSample; 18 | import com.esri.core.geometry.Polygon; 19 | 20 | /** 21 | * Interface for readers of {@link MatcherSample} data from different sources. 22 | */ 23 | public interface SampleReader { 24 | /** 25 | * Checks if the reader is open. 26 | * 27 | * @return True if reader is open, false otherwise. 28 | */ 29 | boolean isOpen(); 30 | 31 | /** 32 | * Opens the reader. 33 | * 34 | * @throws SourceException thrown if an error occurs while handling the source. 35 | */ 36 | void open() throws SourceException; 37 | 38 | /** 39 | * Gets next {@link MatcherSample} object from the source. If all samples have been read, it 40 | * returns null. 41 | * 42 | * @return {@link MatcherSample} object, null if all samples have been read. 43 | * @throws SourceException thrown if an error occurs while reading from source. 44 | */ 45 | MatcherSample next() throws SourceException; 46 | 47 | /** 48 | * Opens the reader and restricts reading of {@link MatcherSample} objects to spatially 49 | * contained or overlapping with a {@link Polygon} and to a temporal timeframe starting at a 50 | * certain time 51 | * 52 | * @param polygon Spatial restriction for reading with a certain {@link Polygon}. Must be null 53 | * to disallow spatial restriction. 54 | * @param time Temporal restriction for reading {@link MatcherSample} objects measured at some 55 | * {@link Date} or later. Must be null to disallow temporal restriction. 56 | * @throws SourceException thrown if an error occurs while handling the source. 57 | */ 58 | public void open(Polygon polygon, Date time) throws SourceException; 59 | 60 | /** 61 | * Closes the reader. 62 | * 63 | * @throws SourceException thrown if an error occurs while handling the source. 64 | */ 65 | void close() throws SourceException; 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Sextuple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | /** 17 | * Generic 6-tuple (sextuple). 18 | * 19 | * @param Type of first element. 20 | * @param Type of second element. 21 | * @param Type of third element. 22 | * @param Type of fourth element. 23 | * @param Type of fifth element. 24 | * @param Type of sixth element. 25 | */ 26 | public class Sextuple extends Quintuple { 27 | private static final long serialVersionUID = 1L; 28 | private F six = null; 29 | 30 | /** 31 | * Creates a {@link Sextuple} object. 32 | * 33 | * @param one First element. 34 | * @param two Second element. 35 | * @param three Third element. 36 | * @param four Fourth element. 37 | * @param five Fifth element. 38 | * @param six Sixth element. 39 | */ 40 | public Sextuple(A one, B two, C three, D four, E five, F six) { 41 | super(one, two, three, four, five); 42 | this.six = six; 43 | } 44 | 45 | /** 46 | * Sets sixth element. 47 | * 48 | * @param six Sixth element. 49 | */ 50 | public void six(F six) { 51 | this.six = six; 52 | } 53 | 54 | /** 55 | * Gets sixth element. 56 | * 57 | * @return Sixth element, may be null if set to null previously. 58 | */ 59 | public F six() { 60 | return six; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/SourceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | 17 | /** 18 | * Exception for handling any sort of data sources. 19 | */ 20 | public class SourceException extends RuntimeException { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | /** 25 | * Creates a {@link SourceException} with an error message. 26 | * 27 | * @param message Message of the exception. 28 | */ 29 | public SourceException(String message) { 30 | super(message); 31 | } 32 | 33 | /** 34 | * Creates a {@link SourceException} with an error message and stack trace. 35 | * 36 | * @param message Message of the exception. 37 | * @param inner Inner exception wrapped by this exception. 38 | */ 39 | public SourceException(String message, Exception inner) { 40 | super(message, inner); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Stopwatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | /** 17 | * Stopwatch of performance benchmarks. 18 | *

19 | * Note: It uses the {@link System#nanoTime()} and, consequently, inherits its accuracy for 20 | * time measurements. 21 | */ 22 | public class Stopwatch { 23 | private long timestamp = 0; 24 | private long time = 0; 25 | 26 | /** 27 | * Starts time measurement. 28 | */ 29 | public void start() { 30 | timestamp = System.nanoTime(); 31 | } 32 | 33 | /** 34 | * Stops time measurement. 35 | */ 36 | public void stop() { 37 | time = System.nanoTime() - timestamp; 38 | } 39 | 40 | /** 41 | * Gets time measurement in nanosceonds. 42 | * 43 | * @return Time measurement in nanoseconds. 44 | */ 45 | public long ns() { 46 | return time; 47 | } 48 | 49 | /** 50 | * Gets time measurement in microsceonds. 51 | * 52 | * @return Time measurement in microseconds. 53 | */ 54 | public long us() { 55 | return time / 1000; 56 | } 57 | 58 | /** 59 | * Gets time measurement in milliseconds. 60 | * 61 | * @return Time measurement in milliseconds. 62 | */ 63 | public long ms() { 64 | return time / 1000000; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/TimedSampleReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.util.Calendar; 17 | import java.util.Date; 18 | 19 | import com.bmwcarit.barefoot.matcher.MatcherSample; 20 | import com.esri.core.geometry.Polygon; 21 | 22 | /** 23 | * Timed reader that wraps other {@link SampleReader} implementations, i.e. it delays output of 24 | * function {@link SampleReader#next()} to generate a real-time stream. It implements the interface 25 | * {@link SampleReader#next()} itself where {@link TimedSampleReader#next()} blocks the current 26 | * thread to apply delays. 27 | */ 28 | public class TimedSampleReader implements SampleReader { 29 | private Long start = null, first = null, last = null; 30 | private final SampleReader reader; 31 | 32 | /** 33 | * Creates {@link TimedSampleReader} as wrapper of another {@link SampleReader} object. 34 | * 35 | * @param reader Reader to be wrapped. 36 | */ 37 | public TimedSampleReader(SampleReader reader) { 38 | this.reader = reader; 39 | } 40 | 41 | @Override 42 | public boolean isOpen() { 43 | return reader.isOpen(); 44 | } 45 | 46 | @Override 47 | public void open() throws SourceException { 48 | if (!reader.isOpen()) { 49 | reader.open(); 50 | } 51 | } 52 | 53 | @Override 54 | public void open(Polygon polygon, Date time) throws SourceException { 55 | if (!reader.isOpen()) { 56 | reader.open(polygon, time); 57 | } 58 | } 59 | 60 | @Override 61 | public MatcherSample next() throws SourceException { 62 | MatcherSample sample = reader.next(); 63 | 64 | if (sample == null) { 65 | return null; 66 | } 67 | 68 | if (start == null || first == null) { 69 | start = Calendar.getInstance().getTime().getTime(); 70 | first = sample.time(); 71 | last = first; 72 | return sample; 73 | } 74 | 75 | if (last > sample.time()) { 76 | throw new SourceException("Stream is unordered from source."); 77 | } 78 | 79 | long diff = (sample.time() - first) - (Calendar.getInstance().getTime().getTime() - start); 80 | try { 81 | Thread.sleep(diff < 0 ? 0 : diff); 82 | } catch (InterruptedException e) { 83 | System.out.println("Delaying thread for timing failed."); 84 | e.printStackTrace(); 85 | } 86 | 87 | return sample; 88 | } 89 | 90 | @Override 91 | public void close() throws SourceException { 92 | reader.close(); 93 | start = null; 94 | first = null; 95 | last = null; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Triple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.io.Serializable; 17 | 18 | /** 19 | * Generic 3-tuple (triple). 20 | * 21 | * @param Type of first element. 22 | * @param Type of second element. 23 | * @param Type of third element. 24 | */ 25 | public class Triple extends Tuple implements Serializable { 26 | private static final long serialVersionUID = 1L; 27 | private Z three = null; 28 | 29 | /** 30 | * Creates a {@link Triple} object. 31 | * 32 | * @param one First element. 33 | * @param two Second element. 34 | * @param three Third element. 35 | */ 36 | public Triple(X one, Y two, Z three) { 37 | super(one, two); 38 | this.three = three; 39 | } 40 | 41 | /** 42 | * Gets third element. 43 | * 44 | * @return Third element, may be null if set to null previously. 45 | */ 46 | public Z three() { 47 | return three; 48 | } 49 | 50 | /** 51 | * Sets third element. 52 | * 53 | * @param three Third element. 54 | */ 55 | public void three(Z three) { 56 | this.three = three; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/Tuple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.util; 15 | 16 | import java.io.Serializable; 17 | 18 | /** 19 | * Generic 2-tuple (tuple). 20 | * 21 | * @param Type of first element. 22 | * @param Type of second element. 23 | */ 24 | public class Tuple implements Serializable { 25 | private static final long serialVersionUID = 1L; 26 | private X one = null; 27 | private Y two = null; 28 | 29 | /** 30 | * Creates a {@link Tuple} object. 31 | * 32 | * @param one First element. 33 | * @param two Second element. 34 | */ 35 | public Tuple(X one, Y two) { 36 | this.one = one; 37 | this.two = two; 38 | } 39 | 40 | /** 41 | * Gets first element. 42 | * 43 | * @return First element, may be null if set to null previously. 44 | */ 45 | public X one() { 46 | return one; 47 | } 48 | 49 | /** 50 | * Gets second element. 51 | * 52 | * @return Second element, may be null if set to null previously. 53 | */ 54 | public Y two() { 55 | return two; 56 | } 57 | 58 | /** 59 | * Sets first element. 60 | * 61 | * @param one First element. 62 | */ 63 | public void one(X one) { 64 | this.one = one; 65 | } 66 | 67 | /** 68 | * Sets second element. 69 | * 70 | * @param two Second element. 71 | */ 72 | public void two(Y two) { 73 | this.two = two; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/bmwcarit/barefoot/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Utilities including tuples types, time measurement, PostgreSQL database access, TCP/IP server, 16 | * and others. 17 | */ 18 | package com.bmwcarit.barefoot.util; 19 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | System.out 4 | 9 | 10 | 11 | %d %-5level [%thread] %logger{0}: %msg%n 12 | 13 | 14 | 15 | 16 | test-trace.log 17 | 18 | 19 | %d %-5level [%thread] %logger{0}: %msg%n 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/analysis/NYCSample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.analysis; 15 | 16 | import java.io.BufferedReader; 17 | import java.io.FileReader; 18 | import java.io.IOException; 19 | import java.text.ParseException; 20 | import java.text.SimpleDateFormat; 21 | import java.util.LinkedList; 22 | import java.util.List; 23 | 24 | import com.bmwcarit.barefoot.util.Tuple; 25 | import com.esri.core.geometry.Point; 26 | 27 | public class NYCSample { 28 | private static List> sources = null; 29 | private static List> targets = null; 30 | 31 | public static void load() throws NumberFormatException, IOException, ParseException { 32 | sources = new LinkedList<>(); 33 | targets = new LinkedList<>(); 34 | String file = 35 | NYCSample.class.getResource("xba96de419e711691b9445d6a6307c170.csv").getFile(); 36 | BufferedReader reader = new BufferedReader(new FileReader(file)); 37 | String line = null; 38 | Point point = null; 39 | Long time = null; 40 | while ((line = reader.readLine()) != null) { 41 | String[] str = line.split(","); 42 | point = new Point(Double.parseDouble(str[10]), Double.parseDouble(str[11])); 43 | time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str[5]).getTime(); 44 | sources.add(new Tuple<>(point, time / 1000)); 45 | 46 | point = new Point(Double.parseDouble(str[12]), Double.parseDouble(str[13])); 47 | time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str[6]).getTime(); 48 | targets.add(new Tuple<>(point, time / 1000)); 49 | } 50 | reader.close(); 51 | } 52 | 53 | public static List> sources() 54 | throws NumberFormatException, IOException, ParseException { 55 | if (sources == null) { 56 | load(); 57 | } 58 | return sources; 59 | } 60 | 61 | public static List> targets() 62 | throws NumberFormatException, IOException, ParseException { 63 | if (targets == null) { 64 | load(); 65 | } 66 | return targets; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/matcher/MatcherSampleTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.matcher; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | 17 | import org.junit.Test; 18 | 19 | import com.esri.core.geometry.Point; 20 | 21 | public class MatcherSampleTest { 22 | 23 | @Test 24 | public void testHeading() { 25 | { 26 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), -0.1); 27 | assertEquals(sample.azimuth(), 359.9, 1E-10); 28 | } 29 | { 30 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), -359.9); 31 | assertEquals(sample.azimuth(), 0.1, 1E-10); 32 | } 33 | { 34 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), -360.1); 35 | assertEquals(sample.azimuth(), 359.9, 1E-10); 36 | } 37 | { 38 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), 360); 39 | assertEquals(sample.azimuth(), 0.0, 1E-10); 40 | } 41 | { 42 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), 360.1); 43 | assertEquals(sample.azimuth(), 0.1, 1E-10); 44 | } 45 | { 46 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), 720.1); 47 | assertEquals(sample.azimuth(), 0.1, 1E-10); 48 | } 49 | { 50 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), -719.9); 51 | assertEquals(sample.azimuth(), 0.1, 1E-10); 52 | } 53 | { 54 | MatcherSample sample = new MatcherSample(0L, new Point(1, 1), -720.1); 55 | assertEquals(sample.azimuth(), 359.9, 1E-10); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/matcher/ServerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.matcher; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.FileInputStream; 20 | import java.io.IOException; 21 | import java.io.InputStreamReader; 22 | import java.io.PrintWriter; 23 | import java.net.InetAddress; 24 | import java.net.Socket; 25 | import java.nio.charset.Charset; 26 | import java.nio.file.Files; 27 | import java.nio.file.Paths; 28 | import java.text.ParseException; 29 | import java.util.Properties; 30 | 31 | import org.json.JSONArray; 32 | import org.json.JSONException; 33 | import org.json.JSONObject; 34 | import org.junit.Test; 35 | 36 | import com.bmwcarit.barefoot.matcher.MatcherServer.GeoJSONOutputFormatter; 37 | import com.bmwcarit.barefoot.matcher.MatcherServer.InputFormatter; 38 | import com.bmwcarit.barefoot.matcher.MatcherServer.OutputFormatter; 39 | 40 | public class ServerTest { 41 | 42 | private class Server implements Runnable { 43 | @Override 44 | public void run() { 45 | ServerControl.initServer("config/server.properties", "config/oberbayern.properties", 46 | new InputFormatter(), new OutputFormatter()); 47 | ServerControl.runServer(); 48 | } 49 | 50 | public void start() { 51 | (new Thread(this)).start(); 52 | } 53 | 54 | public void stop() { 55 | ServerControl.stopServer(); 56 | } 57 | } 58 | 59 | private void sendRequest(InetAddress host, int port, JSONArray samples) 60 | throws InterruptedException, IOException, JSONException { 61 | int trials = 120; 62 | int timeout = 500; 63 | Socket client = null; 64 | 65 | while (client == null || !client.isConnected()) { 66 | try { 67 | client = new Socket(host, port); 68 | } catch (IOException e) { 69 | Thread.sleep(timeout); 70 | 71 | if (trials == 0) { 72 | client.close(); 73 | throw new IOException(e.getMessage()); 74 | } else { 75 | trials -= 1; 76 | } 77 | } 78 | } 79 | 80 | PrintWriter writer = new PrintWriter(client.getOutputStream()); 81 | BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream())); 82 | writer.println(samples.toString()); 83 | writer.flush(); 84 | 85 | String code = reader.readLine(); 86 | assertEquals("SUCCESS", code); 87 | 88 | String response = reader.readLine(); 89 | client.close(); 90 | 91 | MatcherKState state = new MatcherKState(new JSONObject(response), 92 | new MatcherFactory(ServerControl.getServer().getMap())); 93 | 94 | OutputFormatter output = new GeoJSONOutputFormatter(); 95 | PrintWriter out = new PrintWriter( 96 | ServerTest.class.getResource("").getPath() + "ServerTest-matching.json"); 97 | out.println(output.format(null, state)); 98 | out.close(); 99 | 100 | assertEquals(samples.length(), state.sequence().size()); 101 | } 102 | 103 | @Test 104 | public void testServer() 105 | throws IOException, JSONException, InterruptedException, ParseException { 106 | Server server = new Server(); 107 | InetAddress host = InetAddress.getLocalHost(); 108 | Properties properties = new Properties(); 109 | properties.load(new FileInputStream("config/server.properties")); 110 | int port = Integer.parseInt(properties.getProperty("server.port")); 111 | 112 | server.start(); 113 | { 114 | String json = new String( 115 | Files.readAllBytes( 116 | Paths.get(ServerTest.class.getResource("x0001-015.json").getPath())), 117 | Charset.defaultCharset()); 118 | sendRequest(host, port, new JSONArray(json)); 119 | } 120 | server.stop(); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/road/BfmapReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.road; 14 | 15 | import static org.junit.Assert.assertTrue; 16 | import static org.junit.Assert.fail; 17 | 18 | import java.io.IOException; 19 | import java.util.HashSet; 20 | 21 | import org.json.JSONException; 22 | import org.junit.Test; 23 | 24 | import com.bmwcarit.barefoot.roadmap.Testmap; 25 | import com.bmwcarit.barefoot.roadmap.Road; 26 | import com.bmwcarit.barefoot.roadmap.RoadMap; 27 | 28 | public class BfmapReaderTest { 29 | 30 | @Test 31 | public void testBfmapReader() throws IOException, JSONException { 32 | { 33 | RoadWriter writer = new BfmapWriter( 34 | BfmapReaderTest.class.getResource("").getPath() + "oberbayern.bfmap.test"); 35 | RoadReader reader = Testmap.instance().reader(); 36 | BaseRoad road = null; 37 | 38 | writer.open(); 39 | reader.open(); 40 | while ((road = reader.next()) != null) { 41 | writer.write(road); 42 | } 43 | reader.close(); 44 | writer.close(); 45 | } 46 | 47 | HashSet set = new HashSet<>(); 48 | 49 | { 50 | RoadMap map = Testmap.instance(); 51 | RoadReader reader = new BfmapReader( 52 | BfmapReaderTest.class.getResource("oberbayern.bfmap.test").getPath()); 53 | BaseRoad road = null; 54 | 55 | reader.open(); 56 | while ((road = reader.next()) != null) { 57 | Road other = map.get(road.id() * 2); 58 | 59 | if (other == null) { 60 | fail(); 61 | } 62 | 63 | assertTrue(road.source() == other.source()); 64 | assertTrue(road.target() == other.target()); 65 | assertTrue(road.refid() == other.base().refid()); 66 | 67 | if (set.contains(road.id())) { 68 | fail(); 69 | } else { 70 | set.add(road.id()); 71 | } 72 | } 73 | reader.close(); 74 | } 75 | 76 | { 77 | RoadReader reader = Testmap.instance().reader(); 78 | BaseRoad road = null; 79 | 80 | reader.open(); 81 | while ((road = reader.next()) != null) { 82 | if (!set.contains(road.id())) { 83 | fail(); 84 | } 85 | } 86 | reader.close(); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/road/PostGISReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.road; 15 | 16 | import static org.junit.Assert.assertTrue; 17 | 18 | import java.io.FileInputStream; 19 | import java.io.IOException; 20 | import java.util.Arrays; 21 | import java.util.HashSet; 22 | import java.util.Properties; 23 | 24 | import org.json.JSONException; 25 | import org.junit.Test; 26 | 27 | import com.bmwcarit.barefoot.roadmap.Loader; 28 | import com.esri.core.geometry.Geometry.Type; 29 | import com.esri.core.geometry.GeometryEngine; 30 | import com.esri.core.geometry.Polygon; 31 | import com.esri.core.geometry.SpatialReference; 32 | import com.esri.core.geometry.WktImportFlags; 33 | 34 | public class PostGISReaderTest { 35 | 36 | @Test 37 | public void testPostGISReader() throws IOException, JSONException { 38 | Properties properties = new Properties(); 39 | properties.load(new FileInputStream("config/oberbayern.properties")); 40 | RoadReader reader = Loader.reader(properties); 41 | boolean readone = false; 42 | 43 | reader.open(); 44 | 45 | while ((reader.next()) != null) { 46 | readone = true; 47 | break; // Read only first line for testing 48 | } 49 | 50 | reader.close(); 51 | 52 | assertTrue(readone); 53 | } 54 | 55 | @Test 56 | public void testPolygon() throws IOException, JSONException { 57 | Properties properties = new Properties(); 58 | properties.load(new FileInputStream("config/oberbayern.properties")); 59 | RoadReader reader = Loader.reader(properties); 60 | Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt( 61 | "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))", 62 | WktImportFlags.wktImportDefaults, Type.Polygon); 63 | BaseRoad road = null; 64 | 65 | reader.open(polygon, null); 66 | int count = 0; 67 | 68 | while ((road = reader.next()) != null) { 69 | assertTrue( 70 | GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326)) 71 | || GeometryEngine.contains(polygon, road.geometry(), 72 | SpatialReference.create(4326))); 73 | count += 1; 74 | } 75 | 76 | reader.close(); 77 | assertTrue(count > 0); 78 | } 79 | 80 | @Test 81 | public void testExclusion() throws IOException, JSONException { 82 | Properties properties = new Properties(); 83 | properties.load(new FileInputStream("config/oberbayern.properties")); 84 | RoadReader reader = Loader.reader(properties); 85 | Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt( 86 | "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))", 87 | WktImportFlags.wktImportDefaults, Type.Polygon); 88 | HashSet exclusion = new HashSet<>(Arrays.asList((short) 117)); 89 | BaseRoad road = null; 90 | 91 | reader.open(polygon, exclusion); 92 | int count = 0; 93 | 94 | while ((road = reader.next()) != null) { 95 | assertTrue( 96 | GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326)) 97 | || GeometryEngine.contains(polygon, road.geometry(), 98 | SpatialReference.create(4326))); 99 | assertTrue(!exclusion.contains(road.type())); 100 | count += 1; 101 | } 102 | 103 | reader.close(); 104 | assertTrue(count > 0); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/roadmap/RoadPointTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | 18 | import org.json.JSONException; 19 | import org.json.JSONObject; 20 | import org.junit.Test; 21 | 22 | import com.bmwcarit.barefoot.road.BaseRoad; 23 | import com.bmwcarit.barefoot.road.Heading; 24 | import com.esri.core.geometry.Geometry; 25 | import com.esri.core.geometry.GeometryEngine; 26 | import com.esri.core.geometry.Polyline; 27 | import com.esri.core.geometry.WktImportFlags; 28 | 29 | public class RoadPointTest { 30 | 31 | @Test 32 | public void testJSON() throws JSONException { 33 | String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)"; 34 | BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F, 35 | (Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, 36 | Geometry.Type.Polyline)); 37 | 38 | RoadMap map = new RoadMap(); 39 | map.add(new Road(osm, Heading.forward)); 40 | 41 | RoadPoint point1 = new RoadPoint(map.get(0L), 0.2); 42 | 43 | String json = point1.toJSON().toString(); 44 | RoadPoint point2 = RoadPoint.fromJSON(new JSONObject(json), map); 45 | 46 | assertEquals(point1.edge().id(), point2.edge().id()); 47 | assertEquals(point1.fraction(), point2.fraction(), 1E-6); 48 | assertEquals(point1.edge().source(), point2.edge().source()); 49 | assertEquals(point1.edge().target(), point2.edge().target()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/roadmap/RoadTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | 18 | import org.json.JSONException; 19 | import org.json.JSONObject; 20 | import org.junit.Test; 21 | 22 | import com.bmwcarit.barefoot.road.BaseRoad; 23 | import com.bmwcarit.barefoot.road.Heading; 24 | import com.esri.core.geometry.Geometry; 25 | import com.esri.core.geometry.GeometryEngine; 26 | import com.esri.core.geometry.Point; 27 | import com.esri.core.geometry.Polyline; 28 | import com.esri.core.geometry.WktImportFlags; 29 | 30 | public class RoadTest { 31 | 32 | @Test 33 | public void testInvert() { 34 | { 35 | String wkt = "LINESTRING(11.3136273 48.0972002)"; 36 | Polyline line = (Polyline) GeometryEngine.geometryFromWkt(wkt, 37 | WktImportFlags.wktImportDefaults, Geometry.Type.Polyline); 38 | 39 | Polyline invert = Road.invert(line); 40 | 41 | assertEquals(line.getPointCount(), invert.getPointCount()); 42 | 43 | for (int i = 0; i < line.getPointCount(); ++i) { 44 | Point p1 = line.getPoint(i); 45 | Point p2 = invert.getPoint(invert.getPointCount() - (i + 1)); 46 | 47 | assertEquals(p1.getX(), p2.getX(), 1E-6); 48 | assertEquals(p1.getY(), p2.getY(), 1E-6); 49 | } 50 | } 51 | { 52 | String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)"; 53 | Polyline line = (Polyline) GeometryEngine.geometryFromWkt(wkt, 54 | WktImportFlags.wktImportDefaults, Geometry.Type.Polyline); 55 | 56 | Polyline invert = Road.invert(line); 57 | 58 | assertEquals(line.getPointCount(), invert.getPointCount()); 59 | 60 | for (int i = 0; i < line.getPointCount(); ++i) { 61 | Point p1 = line.getPoint(i); 62 | Point p2 = invert.getPoint(invert.getPointCount() - (i + 1)); 63 | 64 | assertEquals(p1.getX(), p2.getX(), 1E-6); 65 | assertEquals(p1.getY(), p2.getY(), 1E-6); 66 | } 67 | } 68 | { 69 | String wkt = 70 | "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999,11.3144345 48.097396, " 71 | + "11.315083 48.0974541,11.3160925 48.0975102,11.3164787 48.0974529," 72 | + "11.3166131 48.0973939,11.31675 48.0972933,11.3168554 48.0971529," 73 | + "11.3168846 48.0969582,11.3167847 48.0967698,11.3166735 48.0966731," 74 | + "11.316501 48.096578,11.316015 48.0964988,11.3153612 48.0964801," 75 | + "11.3141303 48.0965022)"; 76 | Polyline line = (Polyline) GeometryEngine.geometryFromWkt(wkt, 77 | WktImportFlags.wktImportDefaults, Geometry.Type.Polyline); 78 | 79 | Polyline invert = Road.invert(line); 80 | 81 | assertEquals(line.getPointCount(), invert.getPointCount()); 82 | 83 | for (int i = 0; i < line.getPointCount(); ++i) { 84 | Point p1 = line.getPoint(i); 85 | Point p2 = invert.getPoint(invert.getPointCount() - (i + 1)); 86 | 87 | assertEquals(p1.getX(), p2.getX(), 1E-6); 88 | assertEquals(p1.getY(), p2.getY(), 1E-6); 89 | } 90 | } 91 | } 92 | 93 | @Test 94 | public void testJSON() throws JSONException { 95 | String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)"; 96 | BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F, 97 | (Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, 98 | Geometry.Type.Polyline)); 99 | 100 | Road road = new Road(osm, Heading.forward); 101 | RoadMap map = new RoadMap(); 102 | map.add(road); 103 | 104 | String json = road.toJSON().toString(); 105 | Road road2 = Road.fromJSON(new JSONObject(json), map); 106 | 107 | assertEquals(road, road2); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/roadmap/Testmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.roadmap; 15 | 16 | import java.io.IOException; 17 | import java.util.Set; 18 | 19 | import org.json.JSONException; 20 | 21 | import com.esri.core.geometry.GeometryEngine; 22 | import com.esri.core.geometry.Point; 23 | 24 | public class Testmap { 25 | private static RoadMap map = null; 26 | 27 | public static RoadMap instance() throws IOException, JSONException { 28 | if (map != null) { 29 | return map; 30 | } else { 31 | return (map = Loader.roadmap("config/oberbayern.properties", true).construct()); 32 | } 33 | } 34 | 35 | // @Test 36 | public void testRadiusSearch() throws IOException, JSONException { 37 | RoadMap map = instance(); 38 | 39 | Point c = new Point(11.550474464893341, 48.034123185269095); 40 | double r = 50; 41 | Set points = map.spatial().radius(c, r); 42 | 43 | for (RoadPoint point : points) { 44 | System.out.println(GeometryEngine.geometryToGeoJson(point.geometry())); 45 | System.out.println(GeometryEngine.geometryToGeoJson(point.edge().geometry())); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/spatial/SpatialExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | package com.bmwcarit.barefoot.spatial; 14 | 15 | import java.io.IOException; 16 | import java.util.Set; 17 | 18 | import org.junit.Test; 19 | 20 | import com.bmwcarit.barefoot.roadmap.Loader; 21 | import com.bmwcarit.barefoot.roadmap.RoadMap; 22 | import com.bmwcarit.barefoot.roadmap.RoadPoint; 23 | import com.bmwcarit.barefoot.util.SourceException; 24 | import com.esri.core.geometry.GeometryEngine; 25 | import com.esri.core.geometry.Point; 26 | 27 | public class SpatialExample { 28 | 29 | @Test 30 | public void test() throws SourceException, IOException { 31 | // Load and construct road map 32 | RoadMap map = Loader.roadmap("oberbayern.properties", true).construct(); 33 | 34 | Point c = new Point(11.550474464893341, 48.034123185269095); 35 | double r = 50; // radius search within 50 meters 36 | Set points = map.spatial().radius(c, r); 37 | 38 | for (RoadPoint point : points) { 39 | GeometryEngine.geometryToGeoJson(point.geometry()); 40 | GeometryEngine.geometryToGeoJson(point.edge().geometry()); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/bmwcarit/barefoot/topology/EdgeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015, BMW Car IT GmbH 3 | * 4 | * Author: Sebastian Mattheis 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 9 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 11 | * language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.bmwcarit.barefoot.topology; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | import static org.junit.Assert.assertTrue; 18 | 19 | import java.util.HashSet; 20 | import java.util.Iterator; 21 | import java.util.Set; 22 | 23 | import org.junit.Test; 24 | 25 | public class EdgeTest { 26 | @Test 27 | public void testSuccessors() { 28 | Edge edge0 = new Edge(0, 0, 1); 29 | Edge edge1 = new Edge(1, 1, 0); 30 | Edge edge2 = new Edge(2, 1, 2); 31 | Edge edge3 = new Edge(3, 2, 1); 32 | Edge edge4 = new Edge(4, 3, 1); 33 | Edge edge6 = new Edge(6, 4, 0); 34 | Edge edge7 = new Edge(7, 0, 4); 35 | Edge edge8 = new Edge(8, 0, 5); 36 | 37 | edge0.successor(edge1); 38 | edge0.neighbor(edge7); 39 | edge1.successor(edge0); 40 | edge1.neighbor(edge2); 41 | edge2.successor(edge3); 42 | edge2.neighbor(edge1); 43 | edge3.successor(edge2); 44 | edge3.neighbor(edge3); 45 | edge4.successor(edge1); 46 | edge4.neighbor(edge4); 47 | edge6.successor(edge7); 48 | edge6.neighbor(edge6); 49 | edge7.successor(edge6); 50 | edge7.neighbor(edge8); 51 | edge8.successor(null); 52 | edge8.neighbor(edge0); 53 | 54 | { 55 | Set verify = new HashSet<>(); 56 | verify.add(1L); 57 | verify.add(2L); 58 | 59 | Iterator successors = edge0.successors(); 60 | Set out = new HashSet<>(); 61 | 62 | while (successors.hasNext()) { 63 | Edge successor = successors.next(); 64 | assertTrue(verify.contains(successor.id())); 65 | out.add(successor.id()); 66 | } 67 | assertEquals(verify.size(), out.size()); 68 | } 69 | { 70 | Set verify = new HashSet<>(); 71 | verify.add(1L); 72 | verify.add(2L); 73 | 74 | Iterator successors = edge3.successors(); 75 | Set out = new HashSet<>(); 76 | 77 | while (successors.hasNext()) { 78 | Edge successor = successors.next(); 79 | assertTrue(verify.contains(successor.id())); 80 | out.add(successor.id()); 81 | } 82 | assertEquals(verify.size(), out.size()); 83 | } 84 | { 85 | Set verify = new HashSet<>(); 86 | verify.add(0L); 87 | verify.add(7L); 88 | verify.add(8L); 89 | 90 | Iterator successors = edge1.successors(); 91 | Set out = new HashSet<>(); 92 | 93 | while (successors.hasNext()) { 94 | Edge successor = successors.next(); 95 | assertTrue(verify.contains(successor.id())); 96 | out.add(successor.id()); 97 | } 98 | assertEquals(verify.size(), out.size()); 99 | } 100 | { 101 | Set verify = new HashSet<>(); 102 | 103 | Iterator successors = edge8.successors(); 104 | Set out = new HashSet<>(); 105 | 106 | while (successors.hasNext()) { 107 | Edge successor = successors.next(); 108 | assertTrue(verify.contains(successor.id())); 109 | out.add(successor.id()); 110 | } 111 | assertEquals(verify.size(), out.size()); 112 | } 113 | { 114 | Set verify = new HashSet<>(); 115 | verify.add(3L); 116 | 117 | Iterator successors = edge2.successors(); 118 | Set out = new HashSet<>(); 119 | 120 | while (successors.hasNext()) { 121 | Edge successor = successors.next(); 122 | assertTrue(verify.contains(successor.id())); 123 | out.add(successor.id()); 124 | } 125 | assertEquals(verify.size(), out.size()); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/test/resources/com/bmwcarit/barefoot/matcher/x0001-015.geojson: -------------------------------------------------------------------------------- 1 | {"type": "MultiPoint","coordinates": [[11.564388282625075,48.16350662940509],[11.563678490482323,48.16198390379898],[11.563473064247667,48.16122306758928],[11.563349010292418,48.16097334859303],[11.56211307019753,48.16105053673302],[11.562087955592313,48.16105310550876],[11.56050052334351,48.16132139354706],[11.55861940673031,48.16146246902161],[11.55781684760151,48.16150944854922],[11.554951837127055,48.161525422789964],[11.553457873233345,48.16153005345599],[11.553457873233345,48.16153005345599],[11.553457873233345,48.16153005345599],[11.55233027283797,48.16151270819414],[11.549709459760114,48.16086527596004],[11.547606473265642,48.1597561817289],[11.547570796486772,48.15974397345911],[11.547570796486772,48.15974397345911],[11.547133036283018,48.15945941773294],[11.544523986408107,48.1580202520987],[11.541913157899463,48.156621401719875],[11.539193491042212,48.15518473349889],[11.537870061505279,48.154492636215736],[11.537091818020052,48.15415875046126],[11.536790901816994,48.15324523736086],[11.536782512341743,48.15269234254464],[11.5367825123347,48.15269234253445],[11.536781932664688,48.15253742952268],[11.536767679186132,48.15216818658186],[11.536765548739641,48.15216514582384],[11.536765548739641,48.15216514582384],[11.536765548739641,48.15216514582384],[11.536764208930185,48.15215257571192],[11.536717448539342,48.15077090449237],[11.536577179945997,48.14905556426255],[11.536219651738836,48.14672536176703],[11.534835429616662,48.14445337064753],[11.534503792853243,48.14198135739431],[11.53430400751109,48.1395288033757],[11.5344773025581,48.13743976707854],[11.534470202357893,48.13730018550079],[11.534470202357893,48.13730018550079],[11.531785404446792,48.13218461208162],[11.529059374060543,48.13058412140918],[11.526086100168262,48.12895061004929],[11.52328021337131,48.12732106993154],[11.521145118689342,48.12545635319235],[11.518805036284444,48.124154260618575],[11.51406748570058,48.12459192878994],[11.508975207499294,48.1252417046577],[11.502939020366508,48.12592100387197],[11.496993339581742,48.12529215864505],[11.491461076432067,48.124118512381735],[11.485638038697767,48.123746801395],[11.479810083364374,48.12370449280551],[11.474748479784534,48.123736702473806],[11.470046104061598,48.123849470598095],[11.465267017246154,48.124061212453356],[11.460509049709275,48.124453904546556],[11.455741512458177,48.124867832106766],[11.451040963650794,48.12571689514518],[11.44745331533991,48.12728964054621],[11.44820211189581,48.12848367371619],[11.448188695881157,48.12657318984349],[11.447812887681284,48.12579914490477],[11.447674118953156,48.125656474522486],[11.44588547814207,48.125349615749926],[11.443396212779412,48.125157071943434],[11.440394869142446,48.12541468727304],[11.43870044749829,48.126038192952876],[11.438684112060958,48.12604659078717],[11.438684112060958,48.12604659078717],[11.438684112060958,48.12604659078717],[11.438684112060958,48.12604659078717],[11.438667600462034,48.126054460873725],[11.43782808147798,48.12657593323833],[11.437720650170544,48.12666131616615],[11.437500417040214,48.126714126235505],[11.435615169119298,48.127753929402985],[11.433758971976749,48.12851044900588]]} 2 | -------------------------------------------------------------------------------- /src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | System.out 4 | 9 | 10 | 11 | %d %-5level [%thread] %logger{0}: %msg%n 12 | 13 | 14 | 15 | 16 | test-trace.log 17 | 18 | 19 | %d %-5level [%thread] %logger{0}: %msg%n 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /util/monitor/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | -------------------------------------------------------------------------------- /util/monitor/monitor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2016, BMW Car IT GmbH 4 | * 5 | * Author: Sebastian Mattheis 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at 9 | * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 10 | * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | if (process.argv.length != 5 && (process.argv.length != 6 || 16 | (process.argv[5] != 'buffer=true' && process.argv[5] != 'buffer=false'))) { 17 | console.log("usage: monitor [buffer=, default: false]"); 18 | process.exit(1); 19 | } 20 | 21 | var buffer = process.argv.length < 6 ? false : process.argv[5] == 'buffer=true'; 22 | var objects = []; 23 | var zmq = require('zmq'); 24 | var subscriber = zmq.socket('sub'); 25 | subscriber.subscribe(""); 26 | 27 | subscriber.on('message', function(message) { 28 | update = JSON.parse(message); 29 | id = update['id']; 30 | 31 | if (buffer && id in objects && objects[id]['time'] >= update['time']) { 32 | console.log('warning: out of order update for object ' + id); 33 | return; 34 | } 35 | 36 | if (!('point' in update)) { 37 | if (buffer) { 38 | console.log('delete object ' + id); 39 | delete objects[id]; 40 | } 41 | } else if (id in objects) { 42 | if (buffer) { 43 | objects[id] = update; 44 | } 45 | } else { 46 | if (buffer) { 47 | console.log('insert object ' + id); 48 | objects[id] = update; 49 | } 50 | } 51 | 52 | io.emit('message', update); 53 | }); 54 | 55 | var path = require('path') 56 | var express = require('express') 57 | var app = express(); 58 | var http = require('http').Server(app); 59 | var io = require('socket.io')(http); 60 | 61 | app.use(express.static(path.join(__dirname, './public'))); 62 | 63 | app.get('/', function(req, res) { 64 | res.sendfile('index.html'); 65 | }); 66 | 67 | app.get('/messages', function(req, res) { 68 | res.sendfile('index.html'); 69 | }); 70 | 71 | io.on('connection', function(socket) { 72 | console.log('client connected'); 73 | 74 | if (buffer) { 75 | for (var id in objects) { 76 | socket.emit('message', objects[id]); 77 | } 78 | } 79 | 80 | socket.on('disconnect', function() { 81 | console.log('client disconnected'); 82 | }); 83 | }); 84 | 85 | process.on('SIGINT', function() { 86 | console.log('shut down'); 87 | process.exit(); 88 | }); 89 | 90 | if (buffer) { 91 | console.log('connect and listen to tracker (buffered) ...'); 92 | } else { 93 | console.log('connect and listen to tracker (unbuffered) ...'); 94 | } 95 | 96 | subscriber.connect('tcp://' + process.argv[3] + ':' + process.argv[4]); 97 | 98 | http.listen(process.argv[2], function() { 99 | console.log('listening on *:' + process.argv[2]); 100 | }); 101 | -------------------------------------------------------------------------------- /util/monitor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "barefoot-monitor", 3 | "version": "0.1.0", 4 | "license": "Apache-2.0", 5 | "description": "simple barefoot monitor application", 6 | "dependencies": { 7 | "express": "^4.13.4", 8 | "socket.io": "^1.4.4", 9 | "zmq": "^2.14.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /util/monitor/public/messages/index.html: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | Barefoot Monitor (Messages) 18 | 65 | 66 | 67 |

    68 | 69 | 70 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /util/submit/batch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # 4 | # Copyright (C) 2016, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | __author__ = "sebastian.mattheis@bmw-carit.de" 17 | __copyright__ = "Copyright 2016 BMW Car IT GmbH" 18 | __license__ = "Apache-2.0" 19 | 20 | import optparse 21 | import json 22 | import random 23 | import socket 24 | import os 25 | import sys 26 | 27 | parser = optparse.OptionParser("batch.py [options]") 28 | parser.add_option("--host", dest="host", help="IP address of matcher.") 29 | parser.add_option("--port", type="int", dest="port", help="Port of matcher.") 30 | parser.add_option("--file", dest="file", help="JSON file with sample data.") 31 | parser.add_option("--id", dest="id", help="Object id.") 32 | parser.add_option("--zone", dest="zone", default="+0000", help="Time zone in '(+/-)HHMM' format.") 33 | parser.add_option("--format", dest="format", default="geojson", help="Output format: geojson (default) | slimjson | debug") 34 | 35 | (options, args) = parser.parse_args() 36 | 37 | if options.file is None or options.host is None or options.port is None: 38 | parser.print_help() 39 | exit(1) 40 | 41 | if options.format not in ["geojson", "slimjson", "debug"]: 42 | parser.print_help() 43 | exit(1) 44 | 45 | with open(options.file) as jsonfile: 46 | samples = json.load(jsonfile) 47 | 48 | previous = None 49 | 50 | for sample in samples: 51 | if options.id is not None: 52 | sample["id"] = options.id 53 | 54 | tmp = "batch-%s" % random.randint(0, sys.maxint) 55 | file = open(tmp, "w") 56 | try: 57 | try: 58 | file.write( 59 | "{\"format\": \"%s\", \"request\": %s}\n" % 60 | (options.format, json.dumps(samples)) 61 | ) 62 | finally: 63 | file.close() 64 | 65 | output = '' 66 | 67 | s = socket.create_connection((options.host, options.port)) 68 | try: 69 | with open(tmp) as f: 70 | s.sendall(f.read()) 71 | s.shutdown(socket.SHUT_WR) 72 | buf = s.recv(4096) 73 | while buf: 74 | if len(output) < 16: 75 | output += buf 76 | sys.stdout.write(buf) 77 | buf = s.recv(4096) 78 | finally: 79 | s.close() 80 | finally: 81 | os.remove(tmp) 82 | 83 | if not output.startswith('SUCCESS\n'): 84 | sys.exit(1) 85 | -------------------------------------------------------------------------------- /util/submit/stream.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # 4 | # Copyright (C) 2016, BMW Car IT GmbH 5 | # 6 | # Author: Sebastian Mattheis 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 9 | # in compliance with the License. You may obtain a copy of the License at 10 | # http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in 11 | # writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | __author__ = "sebastian.mattheis@bmw-carit.de" 17 | __copyright__ = "Copyright 2016 BMW Car IT GmbH" 18 | __license__ = "Apache-2.0" 19 | 20 | import optparse 21 | import json 22 | import subprocess 23 | import time 24 | import datetime 25 | 26 | parser = optparse.OptionParser("stream.py [options]") 27 | parser.add_option("--host", dest="host", help="IP address of tracker.") 28 | parser.add_option("--port", dest="port", help="Port of tracker.") 29 | parser.add_option("--file", dest="file", help="JSON file with sample data.") 30 | parser.add_option("--id", dest="id", help="Object id.") 31 | parser.add_option("--step", action="store_true", dest="step", default=False, help="Send stepwise.") 32 | 33 | (options, args) = parser.parse_args() 34 | 35 | if options.file == None or options.host == None or options.port == None: 36 | parser.print_help() 37 | exit(1) 38 | 39 | with open(options.file) as jsonfile: 40 | samples = json.load(jsonfile) 41 | 42 | previous = None 43 | 44 | for sample in samples: 45 | if options.id != None: 46 | sample["id"] = options.id 47 | if isinstance(sample['time'], (int, long)): 48 | current = time.mktime(datetime.datetime.fromtimestamp(sample['time'] / 1000).timetuple()) 49 | else: 50 | current = time.mktime(datetime.datetime.strptime(sample['time'][:-5], "%Y-%m-%d %H:%M:%S").timetuple()) 51 | if options.step == True: 52 | raw_input("Press Enter to continue...") 53 | elif previous != None: 54 | time.sleep(current - previous) 55 | previous = current 56 | print(json.dumps(sample)) 57 | subprocess.call("echo '%s' | netcat %s %s" % (json.dumps(sample), options.host, options.port), shell=True) 58 | --------------------------------------------------------------------------------