Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit abb2b7e

Browse files
initial commit
0 parents  commit abb2b7e

File tree

8 files changed

+303
-0
lines changed

8 files changed

+303
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea/**
2+
*.db
3+
*.iml
4+
*.swp
5+
target/**
6+

.template/pom.xml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.giscience.osm-measure-repository</groupId>
5+
<artifactId>{{MeasureName}}</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<dependencies>
9+
<dependency>
10+
<groupId>com.github.mocnik-science</groupId>
11+
<artifactId>osm-measure-repository</artifactId>
12+
<version>master</version>
13+
</dependency>
14+
</dependencies>
15+
<repositories>
16+
<repository>
17+
<id>jitpack.io</id>
18+
<url>https://jitpack.io</url>
19+
</repository>
20+
</repositories>
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<maven.compiler.source>1.8</maven.compiler.source>
24+
<maven.compiler.target>1.8</maven.compiler.target>
25+
</properties>
26+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.giscience.osmMeasures.repository;
2+
3+
import org.giscience.measures.rest.measure.MeasureOSHDB;
4+
import org.giscience.measures.rest.server.RequestParameter;
5+
import org.giscience.measures.tools.Cast;
6+
import org.giscience.utils.geogrid.cells.GridCell;
7+
import org.heigit.bigspatialdata.oshdb.api.mapreducer.MapAggregator;
8+
import org.heigit.bigspatialdata.oshdb.api.object.OSMEntitySnapshot;
9+
10+
import java.util.SortedMap;
11+
12+
public class {{MeasureName}} extends MeasureOSHDB<Number, OSMEntitySnapshot> {
13+
14+
/*
15+
@Override
16+
public Boolean refersToTimeSpan() {
17+
return false;
18+
}
19+
20+
@Override
21+
public Integer defaultDaysBefore() {
22+
return 3 * 12 * 30;
23+
}
24+
25+
@Override
26+
public Integer defaultIntervalInDays() {
27+
return 30;
28+
}
29+
*/
30+
31+
@Override
32+
public SortedMap<GridCell, Number> compute(MapAggregator<GridCell, OSMEntitySnapshot> mapReducer, RequestParameter p) throws Exception {
33+
// EXAMPLE ONLY - PLEASE INSERT CODE HERE
34+
return Cast.result(mapReducer
35+
.osmTag("highway", "motorway")
36+
.count());
37+
// EXAMPLE END
38+
}
39+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Heidelberg University
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# OSM Measure Repository
2+
3+
The `OSM Measure Repository` is a collection of measures for assessing OpenStreetMap (OSM) data. Many measures focus on data quality while others do not, thereby providing context to the data quality measures. The [OSM Measure Repository](https://osm-measure.geog.uni-heidelberg.de) can be used by everyone. New measures can, however, only be added by scientists of the GIScience Group of the Institute of Geography at Heidelberg University.
4+
5+
## Scientific Publications
6+
7+
If you consider this repository to be useful for your work, we would be happy if you would consider publishing our relevant papers:
8+
9+
* F-B Mocnik: **Linked Open Data Vocabularies for Semantically Annotated Repositories of Data Quality Measures** Proceedings of the 10th International Conference on Geographic Information Science (GIScience), 2018
10+
11+
* F-B Mocnik, A Mobasheri, L Griesbaum, M Eckle, C Jacobs, and C Klonner: [**A grounding-based ontology of data quality measures**](http://josis.org/index.php/josis/article/viewFile/360/197) Journal of Spatial Information Science, 16, 2018
12+
13+
* F-B Mocnik: [**A Novel Identifier Scheme for the ISEA Aperture 3 Hexagon Discrete Global Grid System.**](http://doi.org/10.1080/15230406.2018.1455157) Cartography and Geographic Information science, 2018
14+
15+
* F-B Mocnik, A Zipf, and M Raifer: [**The OpenStreetMap folksonomy and its evolution.**](http://doi.org/10.1080/10095020.2017.1368193) Geo-spatial Information Science, 20(3), 2017, 219–230
16+
17+
## Adding a new measure
18+
19+
For adding a measure to the repository, follow the instructions listed below. Please be aware that all measures included in the repository are licensed under the [MIT license](https://github.com/giscience/measures-rest/blob/master/LICENSE).
20+
21+
### Step 1: Fork the Github repository
22+
23+
First, you have to fork the [https://github.com/giscience/osm-measure-repository](https://github.com/giscience/osm-measure-repository). To do so, open the website and click on the button **Fork** at the top right side. You are required to be logged in to create a fork. As a result, you should have your own repository named *https://github.com/your-github-account/osm-measure-repository*.
24+
25+
### Step 2: Create the import in the OSM Measure Repository
26+
27+
Create a new measure in the *OSM Measure Repository*. Click on the <i class="fas fa-edit"/>-symbol and rename the measure to fit your needs. Then, open the code view by clicking on the <i class="fas fa-code"/>-symbol. Insert the following **SOAP directive**:
28+
29+
```java
30+
// import from github/your-name/osm-measure-repository //
31+
```
32+
33+
Observe that you have to adapt the “your-name” part of the directive in order to match your Github account name. Below the code, you will find a short message stating the name that you will use for your JAVA class. If the name of your measure is “Topological completeness”, the name of your JAVA class would be “MeasureTopologicalCompleteness”. Memorize this name because you will need it later.
34+
35+
### Step 3: Clone the Github repository and prepare the measure
36+
37+
For cloning the Github repository to your computer, you can either use a GUI or the command line. If you choose the latter option, you have to type:
38+
39+
```bash
40+
git clone https://github.com/your-github-account/osm-measure-repository
41+
```
42+
43+
Now, you have a local copy of the Github repository on your computer. For preparing a new measure, open a terminal/bash console and navigate to the path in which you have placed the cloned data. In this path, execute:
44+
45+
```bash
46+
./do --add MeasureTopologicalCompleteness
47+
```
48+
49+
Observe that you have to replace the name of the measure by the name that you have memorized in Step 2. Voilà, a directory for the new measure appears. The directory is named accordingly, and it contains a class for a measure.
50+
51+
### Step 4: Implement the measure
52+
53+
Now that you have prepared the measure, you can start with the actual implementation. What you actually do is to overwrite the method `compute` in the JAVA class that you will find in the directory of you measure (`src/...`).
54+
55+
You will find more detailed information about how to implement a measure in the documentation of the library [Measures REST OSHDB](https://gitlab.gistools.geog.uni-heidelberg.de/giscience/dfg-intrinsic-data-quality/measures-rest-oshdb).
56+
57+
### Step 5: Commit and push
58+
59+
In order to make the implementation of the measure including most recent changes available to the *OSM Measure Repository*, you have to commit your changes:
60+
61+
```bash
62+
git add *
63+
git commit -m "MeasureTopologicalCompleteness introduced/improved"
64+
```
65+
66+
Then, you can easily upload the measure to Github:
67+
68+
```bash
69+
git push
70+
```
71+
72+
### Step 6: Run the measure
73+
74+
Go back to the website of the [OSM Measure Repository](https://osm-measure-edit.geog.uni-heidelberg.de). Just enable the measure using the <i class="fas fa-toggle-on"/>-element and (re-)start the server by clicking on the <i class="fas fa-play"/>-symbol.
75+
76+
Congrats, you are done! Your measure should start and be available within the next seconds.
77+
78+
### Step 7 (optional): Publish the measure
79+
80+
Do not forget to even add semantic information about the measure on the website of the [OSM Measure Repository](https://osm-measure-edit.geog.uni-heidelberg.de). This is required when publishing the measure.
81+
82+
Please test the measure in before you want to publish it. Changes are much harder to be made after having published the measure. If you are ready to publish, please go back to your Github repository. There, you will find a button `New pull request`. Use this button to indicate that you would like to publish your measure. Also contact the administrators of the `OSM Measure Repository` in person to discuss the publishing process.
83+
84+
Thank you for contributing!
85+
86+
## Author
87+
88+
This software is written and maintained by the GIScience Research Group, Institute of Geography, Heidelberg University.
89+
90+
The development has been supported by the DFG project *A framework for measuring the fitness for purpose of OpenStreetMap data based on intrinsic quality indicators* (FA 1189/3-1).
91+
92+
(c) by Heidelberg University, 2018.
93+
94+
## License
95+
96+
The code is licensed under the [MIT license](https://github.com/giscience/measures-rest/blob/master/LICENSE).

developer-guidelines.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Developer Guidelines
2+
3+
Please adhere to the following rules:
4+
5+
* The master branch is required to only contain *stable code*.
6+
* Changes need to be *backward compatible*.
7+
8+
In addition, the code and documentation should adhere to the following specification:
9+
10+
| property | Value |
11+
| -------- | ----- |
12+
| indent | 4 spaces |
13+
| code | en-US |
14+
| documentation and comments | en-GB-oxendict |

do

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import os
5+
import re
6+
import shutil
7+
8+
parser = argparse.ArgumentParser(description='Handle the measures of the OSM Measure Repository.')
9+
parser.add_argument('--add', nargs=1, metavar='NameOfMeasure', help='add a measure')
10+
parser.add_argument('--remove', nargs=1, metavar='NameOfMeasure', help='remove a measure')
11+
args = parser.parse_args()
12+
13+
if args.add is None and args.remove is None:
14+
parser.print_help()
15+
16+
## HELPING FUNCTIONS
17+
def rewriteFile(file, f):
18+
with open(file, 'r') as fi:
19+
content = f(fi.read().decode('utf-8'))
20+
with open(file, 'w') as fi:
21+
fi.write(content.encode('utf-8'))
22+
23+
## ADD
24+
if args.add is not None:
25+
measure = args.add[0]
26+
if os.path.exists(measure):
27+
print('''============================ ERROR ===============================
28+
The measure exists already.
29+
==================================================================''')
30+
exit()
31+
if not measure.startswith('Measure'):
32+
print('''============================ ERROR ===============================
33+
The name of the measure must start with \'Measure\'. Please check
34+
for the corresponding name in the OSM Measure Repository. The
35+
name is shown when importing the measure. For more information,
36+
please check the README.md
37+
==================================================================''')
38+
exit()
39+
rewriteFile('pom.xml', lambda content: re.sub('([ \t]+</modules>)', ' <module>' + measure + '</module>\n\g<1>', content))
40+
shutil.copytree('.template', measure)
41+
rewriteFile(os.path.join(measure, 'pom.xml') , lambda content: content.replace('{{MeasureName}}', measure))
42+
rewriteFile(os.path.join(measure, 'src/main/java/org/giscience/osmMeasures/repository/Measure.java') , lambda content: content.replace('{{MeasureName}}', measure))
43+
shutil.move(os.path.join(measure, 'src/main/java/org/giscience/osmMeasures/repository/Measure.java'), os.path.join(measure, 'src/main/java/org/giscience/osmMeasures/repository/' + measure + '.java'))
44+
print('done')
45+
46+
## REMOVE
47+
if args.remove is not None:
48+
measure = args.remove[0]
49+
print('=========================== CAUTION ==============================')
50+
answer = raw_input('Are you sure to delete the directory "' + measure + '"?\n[YES/NO]: ')
51+
if answer != 'YES':
52+
print('cancelling request ...')
53+
exit()
54+
rewriteFile('pom.xml', lambda content: re.sub('[ \t\n]*<module>' + measure + '</module>', '', content))
55+
try:
56+
shutil.rmtree(measure)
57+
except:
58+
pass
59+
print('done')

pom.xml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.giscience.osm-measure-repository</groupId>
5+
<artifactId>root</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>pom</packaging>
8+
<modules>
9+
</modules>
10+
<dependencies>
11+
<dependency>
12+
<groupId>org.giscience.measures</groupId>
13+
<artifactId>measures-rest-oshdb</artifactId>
14+
<version>0.0.1-SNAPSHOT</version>
15+
</dependency>
16+
</dependencies>
17+
<repositories>
18+
<repository>
19+
<snapshots>
20+
<enabled>false</enabled>
21+
</snapshots>
22+
<id>oshdb-releases</id>
23+
<name>Heigit/GIScience maven repository (releases)</name>
24+
<url>http://repo.heigit.org/artifactory/libs-release-local</url>
25+
</repository>
26+
<repository>
27+
<snapshots />
28+
<id>oshdb-snapshots</id>
29+
<name>Heigit/GIScience maven repository (snapshots)</name>
30+
<url>http://repo.heigit.org/artifactory/libs-snapshot-local</url>
31+
</repository>
32+
<repository>
33+
<id>jitpack.io</id>
34+
<url>https://jitpack.io</url>
35+
</repository>
36+
</repositories>
37+
<properties>
38+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39+
<maven.compiler.source>1.8</maven.compiler.source>
40+
<maven.compiler.target>1.8</maven.compiler.target>
41+
</properties>
42+
</project>

0 commit comments

Comments
 (0)