Verified Commit 3851a9e9 authored by Martin Raifer's avatar Martin Raifer
Browse files

Merge branch 'master' into 1.1

parents 89ea2e01 beef6789
1.1.4
-----
* fix a bug triggered when serializing a geometry-type filter
* add license files (LGPL)
1.1.3
-----
* switch to ohsome-parent module
......
pipeline {
agent { label 'master' }
agent {label 'master'}
environment {
RELEASE_REGEX = /^([0-9]+(\.[0-9]+)*)(-(RC|beta-|alpha-)[0-9]+)?$/
......@@ -8,40 +7,53 @@ pipeline {
SNAPSHOT_DEPLOY = false
VERSION = sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev "(^\\[|Download\\w+)"').trim()
PACKAGING = sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.packaging | grep -Ev "(^\\[|Download\\w+)"').trim()
GROUP_ID = sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.groupId | grep -Ev "(^\\[|Download\\w+)"').trim()
ARTIFACT_ID = sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.artifactId | grep -Ev "(^\\[|Download\\w+)"').trim()
MAVEN_TEST_OPTIONS = ' '
}
stages {
stage ('Build and Test') {
steps {
script {
env.MAVEN_HOME = '/usr/share/maven'
author = sh(returnStdout: true, script: 'git show -s --pretty=%an')
echo author
commiti= sh(returnStdout: true, script: 'git log -1')
echo commiti
reponame=sh(returnStdout: true, script: 'basename `git remote get-url origin` .git').trim()
echo reponame
gittiid=sh(returnStdout: true, script: 'git describe --tags --long --always').trim()
echo gittiid
echo env.BRANCH_NAME
echo env.BUILD_NUMBER
echo env.TAG_NAME
if(!(VERSION ==~ RELEASE_REGEX || VERSION ==~ /.*-SNAPSHOT$/)) {
echo 'Version:'
echo VERSION
error 'The version declaration is invalid. It is neither a release nor a snapshot. Mabe some error while fetching it using maven.'
}
}
script {
server = Artifactory.server 'HeiGIT Repo'
rtMaven = Artifactory.newMavenBuild()
rtMaven.resolver server: server, releaseRepo: 'main', snapshotRepo: 'main'
rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'
rtMaven.deployer.addProperty("deployer", "jenkinsOhsome")
rtMaven.deployer.deployArtifacts = false
env.MAVEN_HOME = '/usr/share/maven'
}
script {
withCredentials([string(credentialsId: 'gpg-signing-key-passphrase', variable: 'PASSPHRASE')]) {
buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean compile javadoc:jar source:jar install -Dmaven.repo.local=.m2" -P sign -Dgpg.passphrase=$PASSPHRASE'
buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean compile javadoc:jar source:jar install -P sign,git,withDep -Dmaven.repo.local=.m2 $MAVEN_TEST_OPTIONS -Dgpg.passphrase=$PASSPHRASE'
}
}
}
}
post {
failure {
rocketSend channel: 'jenkinsohsome', emoji: ':sob:' , message: "ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Review the code!" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':sob:' , message: "$reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Review the code!" , rawMessage: true
}
}
}
......@@ -61,7 +73,7 @@ pipeline {
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Is Artifactory running?" , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Deployment of $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Is Artifactory running?" , rawMessage: true
}
}
}
......@@ -82,17 +94,18 @@ pipeline {
file(credentialsId: 'ossrh-settings', variable: 'settingsFile'),
string(credentialsId: 'gpg-signing-key-passphrase', variable: 'PASSPHRASE')
]) {
sh 'mvn -s $settingsFile javadoc:jar source:jar deploy -P sign,deploy-central -Dmaven.repo.local=.m2 -Dgpg.passphrase=$PASSPHRASE -DskipTests=true'
// copy of the above build, since "deploy" does rebuild the packages, without withDep profile
sh 'mvn -s $settingsFile javadoc:jar source:jar deploy -P sign,git,deploy-central -Dmaven.repo.local=.m2 -Dgpg.passphrase=$PASSPHRASE -DskipTests=true'
}
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of oshdb-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Is Artifactory running?" , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Deployment of $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}. Is Artifactory running?" , rawMessage: true
}
}
}
stage ('publish Javadoc') {
stage ('Publish Javadoc') {
when {
anyOf {
equals expected: true, actual: RELEASE_DEPLOY
......@@ -101,30 +114,50 @@ pipeline {
}
steps {
script {
//load dependencies to artifactory
// load dependencies to artifactory
rtMaven.run pom: 'pom.xml', goals: 'org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -Dmaven.repo.local=.m2'
projver=sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev "(^\\[|Download\\w+:)"').trim()
javadc_dir="/srv/javadoc/java/" + reponame + "/" + projver + "/"
javadc_dir="/srv/javadoc/java/" + reponame + "/" + VERSION + "/"
echo javadc_dir
rtMaven.run pom: 'pom.xml', goals: 'clean javadoc:javadoc -Dadditionalparam=-Xdoclint:none -Dmaven.repo.local=.m2'
sh "echo $javadc_dir"
//make shure jenkins uses bash not dash!
// make sure jenkins uses bash not dash!
sh "mkdir -p $javadc_dir && rm -Rf $javadc_dir* && find . -path '*/target/site/apidocs' -exec cp -R --parents {} $javadc_dir \\; && find $javadc_dir -path '*/target/site/apidocs' | while read line; do echo \$line; neu=\${line/target\\/site\\/apidocs/} ; mv \$line/* \$neu ; done && find $javadc_dir -type d -empty -delete"
}
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of javadoc ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Deployment of javadoc $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
}
}
}
stage ('reports and statistics') {
stage ('Reports and Statistics') {
steps {
script {
rtMaven.run pom: 'pom.xml', goals: '--batch-mode -V -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs com.github.spotbugs:spotbugs-maven-plugin:3.1.7:spotbugs -Dmaven.repo.local=.m2'
// jacoco
report_dir="/srv/reports/" + reponame + "/" + VERSION + "_" + env.BRANCH_NAME + "/" + env.BUILD_NUMBER + "_" +gittiid+"/jacoco/"
rtMaven.run pom: 'pom.xml', goals: 'clean verify -Pjacoco -Dmaven.repo.local=.m2 $MAVEN_TEST_OPTIONS'
jacoco(
execPattern : 'target/jacoco.exec',
classPattern : 'target/classes',
sourcePattern : 'src/main/java',
inclusionPattern : '/org/heigit/**'
)
sh "mkdir -p $report_dir && rm -Rf $report_dir* && find . -path '*/target/site/jacoco' -exec cp -R --parents {} $report_dir \\; && find $report_dir -path '*/target/site/jacoco' | while read line; do echo \$line; neu=\${line/target\\/site\\/jacoco/} ; mv \$line/* \$neu ; done && find $report_dir -type d -empty -delete"
// infer
if(env.BRANCH_NAME ==~ /(^master$)/) {
report_dir="/srv/reports/" + reponame + "/" + VERSION + "_" + env.BRANCH_NAME + "/" + env.BUILD_NUMBER + "_" +gittiid+"/infer/"
sh "mvn clean"
sh "infer run --pmd-xml -r -- mvn compile"
sh "mkdir -p $report_dir && rm -Rf $report_dir* && cp -R ./infer-out/* $report_dir"
}
// warnings plugin
rtMaven.run pom: 'pom.xml', goals: '--batch-mode -V -e compile checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs com.github.spotbugs:spotbugs-maven-plugin:3.1.7:spotbugs -Dmaven.repo.local=.m2'
recordIssues enabledForFailure: true, tools: [mavenConsole(), java(), javaDoc()]
recordIssues enabledForFailure: true, tool: checkStyle()
......@@ -132,19 +165,20 @@ pipeline {
recordIssues enabledForFailure: true, tool: spotBugs()
recordIssues enabledForFailure: true, tool: cpd(pattern: '**/target/cpd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/target/pmd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/infer-out/report.xml', id: 'infer')
}
}
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Reporting of ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Reporting of $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
}
}
}
}
stage ('encourage') {
when {
stage ('Encourage') {
when {
expression {
if(currentBuild.number > 1){
if(currentBuild.number > 1) {
datepre=new Date(currentBuild.previousBuild.rawBuild.getStartTimeInMillis()).clearTime()
echo datepre.format( 'yyyyMMdd' )
datenow=new Date(currentBuild.rawBuild.getStartTimeInMillis()).clearTime()
......@@ -155,27 +189,27 @@ pipeline {
}
}
steps {
rocketSend channel: 'jenkinsohsome', message: "Hey, this is just your daily notice that Jenkins is still working for you on ohsome-filter! Happy and for free! Keep it up!" , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Hey, this is just your daily notice that Jenkins is still working for you on $reponame Branch ${env.BRANCH_NAME}! Happy and for free! Keep it up!" , rawMessage: true
}
post {
failure {
rocketSend channel: 'jenkinsohsome', emoji: ':wink:' , message: "Reporting of ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':wink:' , message: "Reporting of $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
}
}
}
}
stage ('Report status change') {
stage ('Report Status Change') {
when {
expression {
return ((currentBuild.number > 1) && (currentBuild.getPreviousBuild().result == 'FAILURE'))
}
}
steps {
rocketSend channel: 'jenkinsohsome', message: "We had some problems, but we are BACK TO NORMAL! Nice debugging: ohsome-filter build-nr. ${env.BUILD_NUMBER} *succeeded* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "We had some problems, but we are BACK TO NORMAL! Nice debugging: $reponame-build-nr. ${env.BUILD_NUMBER} *succeeded* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Reporting of ohsome-filter build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', message: "Reporting of $reponame-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${author}." , rawMessage: true
}
}
}
......
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
......@@ -15,7 +15,7 @@ Add the module to your maven dependencies (`pom.xml`):
<dependency>
<groupId>org.heigit.ohsome</groupId>
<artifactId>ohsome-filter</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</dependency>
<repository>
......
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>ohsome-filter</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<description>A flexible filtering library for OSM entities.</description>
<packaging>jar</packaging>
......@@ -64,10 +64,64 @@
<properties>
<h2.version>1.4.193</h2.version>
<jacoco.version>0.8.5</jacoco.version>
<jetbrains-annotations.version>13.0</jetbrains-annotations.version>
<jparsec.version>3.1</jparsec.version>
<junit.version>4.12</junit.version>
<mavenpmd.version>3.11.0</mavenpmd.version>
<oshdb.version>[0.5,0.6)</oshdb.version>
<pmd.version>6.11.0</pmd.version>
<slf4j-log4j.version>1.7.25</slf4j-log4j.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${mavenpmd.version}</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
......@@ -37,7 +37,6 @@ public class GeometryTypeFilter implements Filter {
private final OSHDBTag typeBoundary;
private final GeometryType geometryType;
private final TagTranslator tagTranslator;
/**
* Returns a new geometry type filter object.
......@@ -46,10 +45,16 @@ public class GeometryTypeFilter implements Filter {
* @param tt Tag Translator object for converting OSM tags to OSHDB tag ids
*/
public GeometryTypeFilter(GeometryType geometryType, TagTranslator tt) {
this.geometryType = geometryType;
this.typeMultipolygon = tt.getOSHDBTagOf(tagTypeMultipolygon);
this.typeBoundary = tt.getOSHDBTagOf(tagTypeBoundary);
this.tagTranslator = tt;
}
private GeometryTypeFilter(
GeometryType geometryType, OSHDBTag typeMultipolygon, OSHDBTag typeBoundary) {
this.geometryType = geometryType;
this.typeMultipolygon = typeMultipolygon;
this.typeBoundary = typeBoundary;
}
/**
......@@ -155,16 +160,16 @@ public class GeometryTypeFilter implements Filter {
"the negation of one geometry type must equal exactly tree geometry types";
return new OrOperator(
new GeometryTypeFilter(otherTypesList.get(0), this.tagTranslator),
new GeometryTypeFilter(otherTypesList.get(0), typeMultipolygon, typeBoundary),
new OrOperator(
new GeometryTypeFilter(otherTypesList.get(1), this.tagTranslator),
new GeometryTypeFilter(otherTypesList.get(2), this.tagTranslator)
new GeometryTypeFilter(otherTypesList.get(1), typeMultipolygon, typeBoundary),
new GeometryTypeFilter(otherTypesList.get(2), typeMultipolygon, typeBoundary)
)
);
}
@Override
public String toString() {
return "geometry:" + geometryType.toString();
return "geometry:" + geometryType.toString().toLowerCase();
}
}
......@@ -40,6 +40,6 @@ public class TagFilterEqualsAny implements TagFilter {
@Override
public String toString() {
return "tag:" + tag.toInt() + "!=*";
return "tag:" + tag.toInt() + "=*";
}
}
......@@ -52,6 +52,6 @@ public class TypeFilter implements Filter {
@Override
public String toString() {
return "type:" + type.toString();
return "type:" + type.toString().toLowerCase();
}
}
package org.heigit.ohsome.filter;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.heigit.bigspatialdata.oshdb.osm.OSMEntity;
import org.junit.Test;
import org.locationtech.jts.geom.GeometryFactory;
/**
* Test class for the ohsome-filter package.
*
* <p>Tests the parsing of filters and the application to OSM entities.</p>
*/
public class ApplyOSMGeometryTest extends FilterTest {
@Test
public void testGeometryTypeFilterPoint() {
FilterExpression expression = parser.parse("geometry:point");
GeometryFactory gf = new GeometryFactory();
assertTrue(expression.applyOSMGeometry(createTestEntityNode(), gf.createPoint()));
}
@Test
public void testGeometryTypeFilterLine() {
FilterExpression expression = parser.parse("geometry:line");
GeometryFactory gf = new GeometryFactory();
OSMEntity validWay = createTestEntityWay(new long[]{1, 2, 3, 4, 1});
assertTrue(expression.applyOSMGeometry(validWay, gf.createLineString()));
assertFalse(expression.applyOSMGeometry(validWay, gf.createPolygon()));
}
@Test
public void testGeometryTypeFilterPolygon() {
FilterExpression expression = parser.parse("geometry:polygon");
GeometryFactory gf = new GeometryFactory();
OSMEntity validWay = createTestEntityWay(new long[]{1, 2, 3, 4, 1});
assertTrue(expression.applyOSMGeometry(validWay, gf.createPolygon()));
assertFalse(expression.applyOSMGeometry(validWay, gf.createLineString()));
OSMEntity validRelation = createTestEntityRelation("type", "multipolygon");
assertTrue(expression.applyOSMGeometry(validRelation, gf.createPolygon()));
assertFalse(expression.applyOSMGeometry(validRelation, gf.createGeometryCollection()));
}
@Test
public void testGeometryTypeFilterOther() {
FilterExpression expression = parser.parse("geometry:other");
GeometryFactory gf = new GeometryFactory();
OSMEntity validRelation = createTestEntityRelation();
assertTrue(expression.applyOSMGeometry(validRelation, gf.createGeometryCollection()));
assertFalse(expression.applyOSMGeometry(validRelation, gf.createPolygon()));
}
}
......@@ -3,97 +3,25 @@ package org.heigit.ohsome.filter;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import org.heigit.bigspatialdata.oshdb.osm.OSMEntity;
import org.heigit.bigspatialdata.oshdb.osm.OSMMember;
import org.heigit.bigspatialdata.oshdb.osm.OSMNode;
import org.heigit.bigspatialdata.oshdb.osm.OSMRelation;
import org.heigit.bigspatialdata.oshdb.osm.OSMType;
import org.heigit.bigspatialdata.oshdb.osm.OSMWay;
import org.heigit.bigspatialdata.oshdb.util.OSHDBTag;
import org.heigit.bigspatialdata.oshdb.util.exceptions.OSHDBKeytablesNotFoundException;