mirror of https://github.com/apache/lucene.git
This removes the last of ant-compatibility hacks - cross-project dependency on test classes. Replaced with gradle's test fixture artifact sharing. Cleaned up spatial3d classes a bit too.
This commit is contained in:
parent
f83c9462bb
commit
fd685682be
|
@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "base"
|
id "base"
|
||||||
id "com.palantir.consistent-versions" version "1.14.0"
|
id "com.palantir.consistent-versions" version "1.28.0"
|
||||||
id "org.owasp.dependencycheck" version "5.3.0"
|
id "org.owasp.dependencycheck" version "5.3.0"
|
||||||
id 'de.thetaphi.forbiddenapis' version '3.1' apply false
|
id 'de.thetaphi.forbiddenapis' version '3.1' apply false
|
||||||
id "de.undercouch.download" version "4.1.1" apply false
|
id "de.undercouch.download" version "4.1.1" apply false
|
||||||
|
@ -167,11 +167,6 @@ apply from: file('gradle/testing/profiling.gradle')
|
||||||
apply from: file('gradle/testing/beasting.gradle')
|
apply from: file('gradle/testing/beasting.gradle')
|
||||||
apply from: file('gradle/help.gradle')
|
apply from: file('gradle/help.gradle')
|
||||||
|
|
||||||
// Ant-compatibility layer. ALL OF THESE SHOULD BE GONE at some point. They are
|
|
||||||
// here so that we can coexist with current ant build but they are indicative
|
|
||||||
// of potential problems with the build conventions, dependencies, etc.
|
|
||||||
apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')
|
|
||||||
|
|
||||||
apply from: file('gradle/documentation/documentation.gradle')
|
apply from: file('gradle/documentation/documentation.gradle')
|
||||||
apply from: file('gradle/documentation/changes-to-html.gradle')
|
apply from: file('gradle/documentation/changes-to-html.gradle')
|
||||||
apply from: file('gradle/documentation/markdown.gradle')
|
apply from: file('gradle/documentation/markdown.gradle')
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set up cross-project dependency on test classes. This should be resolved by pulling reused classes into
|
|
||||||
// a separate regular module. Exporting test classes is sort of weird.
|
|
||||||
configure([project(":lucene:spatial3d"),
|
|
||||||
project(":lucene:analysis:common"),
|
|
||||||
project(":lucene:backward-codecs"),
|
|
||||||
project(":lucene:queryparser")]) {
|
|
||||||
plugins.withType(JavaPlugin) {
|
|
||||||
configurations {
|
|
||||||
testClassesExported
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
testClassesExported sourceSets.test.java.outputDir, {
|
|
||||||
builtBy testClasses
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configure(project(":lucene:spatial-extras")) {
|
|
||||||
plugins.withType(JavaPlugin) {
|
|
||||||
dependencies {
|
|
||||||
testImplementation project(path: ':lucene:spatial3d', configuration: 'testClassesExported')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -84,6 +84,20 @@ configure(subprojects.findAll { it.path in rootProject.published }) { prj ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip any test fixtures in publishing.
|
||||||
|
afterEvaluate {
|
||||||
|
configurations.matching {
|
||||||
|
return it.name in [
|
||||||
|
"testFixturesApiElements",
|
||||||
|
"testFixturesRuntimeElements"
|
||||||
|
]
|
||||||
|
}.all {
|
||||||
|
project.components.java.withVariantsFromConfiguration(it) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do not generate gradle metadata files.
|
// Do not generate gradle metadata files.
|
||||||
tasks.withType(GenerateModuleMetadata) {
|
tasks.withType(GenerateModuleMetadata) {
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
|
@ -69,10 +69,12 @@ allprojects { prj ->
|
||||||
suppressAnnotations += [
|
suppressAnnotations += [
|
||||||
"**.SuppressForbidden"
|
"**.SuppressForbidden"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure defaults for sourceSets.test
|
// Configure defaults for sourceSets.test
|
||||||
forbiddenApisTest {
|
tasks.matching { it.name in ["forbiddenApisTest", "forbiddenApisTestFixtures"] }.all {
|
||||||
bundledSignatures += [
|
bundledSignatures += [
|
||||||
'jdk-unsafe',
|
'jdk-unsafe',
|
||||||
'jdk-deprecated',
|
'jdk-deprecated',
|
||||||
|
@ -87,6 +89,12 @@ allprojects { prj ->
|
||||||
suppressAnnotations += [
|
suppressAnnotations += [
|
||||||
"**.SuppressForbidden"
|
"**.SuppressForbidden"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (it.name == "forbiddenApisTestFixtures") {
|
||||||
|
doFirst dynamicSignatures.curry(configurations.testFixturesCompileClasspath, "lucene")
|
||||||
|
} else {
|
||||||
|
doFirst dynamicSignatures.curry(configurations.testCompileClasspath, "lucene")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure defaults for sourceSets.tools (if present).
|
// Configure defaults for sourceSets.tools (if present).
|
||||||
|
@ -103,9 +111,21 @@ allprojects { prj ->
|
||||||
]
|
]
|
||||||
|
|
||||||
doFirst dynamicSignatures.curry(configurations.toolsCompileClasspath, "lucene")
|
doFirst dynamicSignatures.curry(configurations.toolsCompileClasspath, "lucene")
|
||||||
|
|
||||||
inputs.dir(file(resources))
|
inputs.dir(file(resources))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We rely on resolved configurations to compute the relevant set of rule
|
||||||
|
// files for forbiddenApis. Since we don't want to resolve these configurations until
|
||||||
|
// the task is executed, we can't really use them as task inputs properly. This is a
|
||||||
|
// chicken-and-egg problem.
|
||||||
|
//
|
||||||
|
// This is the simplest workaround possible: just point at all the rule files and indicate
|
||||||
|
// them as inputs. This way if a rule is modified, checks will be reapplied.
|
||||||
|
configure(tasks.matching { it.name.startsWith("forbiddenApis") }) { task ->
|
||||||
|
task.inputs.dir(file(resources))
|
||||||
|
}
|
||||||
|
|
||||||
// Disable sysout signatures for these projects.
|
// Disable sysout signatures for these projects.
|
||||||
if (prj.path in [
|
if (prj.path in [
|
||||||
":lucene:demo",
|
":lucene:demo",
|
||||||
|
@ -116,24 +136,5 @@ allprojects { prj ->
|
||||||
'jdk-system-out'
|
'jdk-system-out'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
forbiddenApisMain {
|
|
||||||
doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")
|
|
||||||
}
|
|
||||||
|
|
||||||
forbiddenApisTest {
|
|
||||||
doFirst dynamicSignatures.curry(configurations.testCompileClasspath, "lucene")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We rely on resolved configurations to compute the relevant set of rule
|
|
||||||
// files for forbiddenApis. Since we don't want to resolve these configurations until
|
|
||||||
// the task is executed, we can't really use them as task inputs properly. This is a
|
|
||||||
// chicken-and-egg problem.
|
|
||||||
//
|
|
||||||
// This is the simplest workaround possible: just point at all the rule files and indicate
|
|
||||||
// them as inputs. This way if a rule is modified, checks will be reapplied.
|
|
||||||
configure([forbiddenApisMain, forbiddenApisTest]) { task ->
|
|
||||||
task.inputs.dir(file(resources))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -1,2 +0,0 @@
|
||||||
@defaultMessage Use org.apache.solr.common.annotation.JsonProperty instead
|
|
||||||
com.fasterxml.jackson.annotation.JsonProperty
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
|
||||||
# this work for additional information regarding copyright ownership.
|
|
||||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
# (the "License"); you may not use this file except in compliance with
|
|
||||||
# the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareFixedThreadPool instead
|
|
||||||
java.util.concurrent.Executors#newFixedThreadPool(int,java.util.concurrent.ThreadFactory)
|
|
||||||
|
|
||||||
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareSingleThreadExecutor instead
|
|
||||||
java.util.concurrent.Executors#newSingleThreadExecutor(java.util.concurrent.ThreadFactory)
|
|
||||||
|
|
||||||
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareCachedThreadPool instead
|
|
||||||
java.util.concurrent.Executors#newCachedThreadPool(java.util.concurrent.ThreadFactory)
|
|
||||||
|
|
||||||
@defaultMessage Use ExecutorUtil.MDCAwareThreadPoolExecutor instead of ThreadPoolExecutor
|
|
||||||
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.ThreadFactory,java.util.concurrent.RejectedExecutionHandler)
|
|
||||||
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue)
|
|
||||||
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.ThreadFactory)
|
|
||||||
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.RejectedExecutionHandler)
|
|
||||||
|
|
||||||
@defaultMessage Use RTimer/TimeOut/System.nanoTime for time comparisons, and `new Date()` output/debugging/stats of timestamps. If for some miscellaneous reason, you absolutely need to use this, use a SuppressForbidden.
|
|
||||||
java.lang.System#currentTimeMillis()
|
|
||||||
|
|
||||||
@defaultMessage Use slf4j classes instead
|
|
||||||
java.util.logging.**
|
|
|
@ -1,20 +0,0 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
|
||||||
# this work for additional information regarding copyright ownership.
|
|
||||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
# (the "License"); you may not use this file except in compliance with
|
|
||||||
# the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
@defaultMessage Creates threads without a thread name
|
|
||||||
java.lang.Thread#<init>()
|
|
||||||
java.lang.Thread#<init>(java.lang.Runnable)
|
|
||||||
java.lang.Thread#<init>(java.lang.ThreadGroup,java.lang.Runnable)
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
|
||||||
# this work for additional information regarding copyright ownership.
|
|
||||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
# (the "License"); you may not use this file except in compliance with
|
|
||||||
# the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
@defaultMessage Servlet API method is parsing request parameters without using the correct encoding if no extra configuration is given in the servlet container
|
|
||||||
|
|
||||||
javax.servlet.ServletRequest#getParameter(java.lang.String)
|
|
||||||
javax.servlet.ServletRequest#getParameterMap()
|
|
||||||
javax.servlet.ServletRequest#getParameterNames()
|
|
||||||
javax.servlet.ServletRequest#getParameterValues(java.lang.String)
|
|
||||||
|
|
||||||
javax.servlet.http.HttpServletRequest#getSession() @ Servlet API getter has side effect of creating sessions
|
|
||||||
|
|
||||||
@defaultMessage Servlet API method is broken and slow in some environments (e.g., Jetty's UTF-8 readers)
|
|
||||||
|
|
||||||
javax.servlet.ServletRequest#getReader()
|
|
||||||
javax.servlet.ServletResponse#getWriter()
|
|
||||||
javax.servlet.ServletInputStream#readLine(byte[],int,int)
|
|
||||||
javax.servlet.ServletOutputStream#print(boolean)
|
|
||||||
javax.servlet.ServletOutputStream#print(char)
|
|
||||||
javax.servlet.ServletOutputStream#print(double)
|
|
||||||
javax.servlet.ServletOutputStream#print(float)
|
|
||||||
javax.servlet.ServletOutputStream#print(int)
|
|
||||||
javax.servlet.ServletOutputStream#print(long)
|
|
||||||
javax.servlet.ServletOutputStream#print(java.lang.String)
|
|
||||||
javax.servlet.ServletOutputStream#println(boolean)
|
|
||||||
javax.servlet.ServletOutputStream#println(char)
|
|
||||||
javax.servlet.ServletOutputStream#println(double)
|
|
||||||
javax.servlet.ServletOutputStream#println(float)
|
|
||||||
javax.servlet.ServletOutputStream#println(int)
|
|
||||||
javax.servlet.ServletOutputStream#println(long)
|
|
||||||
javax.servlet.ServletOutputStream#println(java.lang.String)
|
|
|
@ -1,3 +0,0 @@
|
||||||
@defaultMessage Use slf4j classes instead
|
|
||||||
org.apache.log4j.**
|
|
||||||
org.apache.logging.log4j.**
|
|
|
@ -27,6 +27,7 @@ dependencies {
|
||||||
api 'io.sgr:s2-geometry-library-java'
|
api 'io.sgr:s2-geometry-library-java'
|
||||||
|
|
||||||
testImplementation project(':lucene:test-framework')
|
testImplementation project(':lucene:test-framework')
|
||||||
|
testImplementation testFixtures(project(':lucene:spatial3d'))
|
||||||
|
|
||||||
testImplementation 'org.locationtech.jts:jts-core'
|
testImplementation 'org.locationtech.jts:jts-core'
|
||||||
testImplementation 'org.locationtech.spatial4j:spatial4j::tests'
|
testImplementation 'org.locationtech.spatial4j:spatial4j::tests'
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial.spatial4j;
|
package org.apache.lucene.spatial.spatial4j;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
import static org.locationtech.spatial4j.distance.DistanceUtils.DEGREES_TO_RADIANS;
|
import static org.locationtech.spatial4j.distance.DistanceUtils.DEGREES_TO_RADIANS;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -39,7 +40,6 @@ import org.apache.lucene.spatial3d.geom.GeoPoint;
|
||||||
import org.apache.lucene.spatial3d.geom.GeoPointShape;
|
import org.apache.lucene.spatial3d.geom.GeoPointShape;
|
||||||
import org.apache.lucene.spatial3d.geom.GeoPolygonFactory;
|
import org.apache.lucene.spatial3d.geom.GeoPolygonFactory;
|
||||||
import org.apache.lucene.spatial3d.geom.PlanetModel;
|
import org.apache.lucene.spatial3d.geom.PlanetModel;
|
||||||
import org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.locationtech.spatial4j.shape.Rectangle;
|
import org.locationtech.spatial4j.shape.Rectangle;
|
||||||
import org.locationtech.spatial4j.shape.Shape;
|
import org.locationtech.spatial4j.shape.Shape;
|
||||||
|
@ -47,7 +47,6 @@ import org.locationtech.spatial4j.shape.Shape;
|
||||||
public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
|
public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
|
||||||
|
|
||||||
private PlanetModel planetModel;
|
private PlanetModel planetModel;
|
||||||
private RandomGeo3dShapeGenerator shapeGenerator;
|
|
||||||
private SpatialPrefixTree grid;
|
private SpatialPrefixTree grid;
|
||||||
private RecursivePrefixTreeStrategy rptStrategy;
|
private RecursivePrefixTreeStrategy rptStrategy;
|
||||||
|
|
||||||
|
@ -73,8 +72,7 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupStrategy() {
|
private void setupStrategy() {
|
||||||
shapeGenerator = new RandomGeo3dShapeGenerator();
|
planetModel = randomPlanetModel();
|
||||||
planetModel = shapeGenerator.randomPlanetModel();
|
|
||||||
Geo3dSpatialContextFactory factory = new Geo3dSpatialContextFactory();
|
Geo3dSpatialContextFactory factory = new Geo3dSpatialContextFactory();
|
||||||
factory.planetModel = planetModel;
|
factory.planetModel = planetModel;
|
||||||
ctx = factory.newSpatialContext();
|
ctx = factory.newSpatialContext();
|
||||||
|
@ -135,8 +133,8 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape randomIndexedShape() {
|
protected Shape randomIndexedShape() {
|
||||||
int type = shapeGenerator.randomShapeType();
|
int type = randomShapeType();
|
||||||
GeoAreaShape areaShape = shapeGenerator.randomGeoAreaShape(type, planetModel);
|
GeoAreaShape areaShape = randomGeoAreaShape(type, planetModel);
|
||||||
if (areaShape instanceof GeoPointShape) {
|
if (areaShape instanceof GeoPointShape) {
|
||||||
return new Geo3dPointShape((GeoPointShape) areaShape, ctx);
|
return new Geo3dPointShape((GeoPointShape) areaShape, ctx);
|
||||||
}
|
}
|
||||||
|
@ -145,8 +143,8 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape randomQueryShape() {
|
protected Shape randomQueryShape() {
|
||||||
int type = shapeGenerator.randomShapeType();
|
int type = randomShapeType();
|
||||||
GeoAreaShape areaShape = shapeGenerator.randomGeoAreaShape(type, planetModel);
|
GeoAreaShape areaShape = randomGeoAreaShape(type, planetModel);
|
||||||
return new Geo3dShape<>(areaShape, ctx);
|
return new Geo3dShape<>(areaShape, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'java-test-fixtures'
|
||||||
|
|
||||||
description = '3D spatial planar geometry APIs'
|
description = '3D spatial planar geometry APIs'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':lucene:core')
|
api project(':lucene:core')
|
||||||
|
|
||||||
|
testFixturesApi project(':lucene:test-framework')
|
||||||
testImplementation project(':lucene:test-framework')
|
testImplementation project(':lucene:test-framework')
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
public class TestGeo3DDocValues extends LuceneTestCase {
|
public class TestGeo3DDocValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testBasic() throws Exception {
|
public void testBasic() {
|
||||||
checkPointEncoding(0.0, 0.0);
|
checkPointEncoding(0.0, 0.0);
|
||||||
checkPointEncoding(45.0, 72.0);
|
checkPointEncoding(45.0, 72.0);
|
||||||
checkPointEncoding(-45.0, -100.0);
|
checkPointEncoding(-45.0, -100.0);
|
||||||
|
|
|
@ -17,18 +17,17 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check relationship between polygon and GeoShapes of composite polygons. Normally we construct the
|
* Check relationship between polygon and GeoShapes of composite polygons. Normally we construct the
|
||||||
* composite polygon (when possible) and the complex one.
|
* composite polygon (when possible) and the complex one.
|
||||||
*/
|
*/
|
||||||
public class TestCompositeGeoPolygonRelationships {
|
public class TestCompositeGeoPolygonRelationships extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGeoCompositePolygon1() {
|
public void testGeoCompositePolygon1() {
|
||||||
|
|
|
@ -16,15 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestGeoBBox {
|
public class TestGeoBBox extends LuceneTestCase {
|
||||||
|
|
||||||
protected static final double DEGREES_TO_RADIANS = Math.PI / 180.0;
|
protected static final double DEGREES_TO_RADIANS = Math.PI / 180.0;
|
||||||
|
|
||||||
|
@ -32,7 +29,7 @@ public class TestGeoBBox {
|
||||||
public void testBBoxDegenerate() {
|
public void testBBoxDegenerate() {
|
||||||
GeoBBox box;
|
GeoBBox box;
|
||||||
int relationship;
|
int relationship;
|
||||||
List<GeoPoint> points = new ArrayList<GeoPoint>();
|
List<GeoPoint> points = new ArrayList<>();
|
||||||
points.add(
|
points.add(
|
||||||
new GeoPoint(PlanetModel.SPHERE, -49 * DEGREES_TO_RADIANS, -176 * DEGREES_TO_RADIANS));
|
new GeoPoint(PlanetModel.SPHERE, -49 * DEGREES_TO_RADIANS, -176 * DEGREES_TO_RADIANS));
|
||||||
points.add(
|
points.add(
|
||||||
|
|
|
@ -16,13 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestGeoConvexPolygon {
|
public class TestGeoConvexPolygon extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPolygonPointWithin() {
|
public void testPolygonPointWithin() {
|
||||||
|
|
|
@ -17,11 +17,14 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Tests for GeoExactCircle. */
|
/** Tests for GeoExactCircle. */
|
||||||
public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
|
public class TestGeoExactCircle extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExactCircle() {
|
public void testExactCircle() {
|
||||||
|
@ -78,8 +81,7 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
|
||||||
@Repeat(iterations = 100)
|
@Repeat(iterations = 100)
|
||||||
public void RandomPointBearingWGS84Test() {
|
public void RandomPointBearingWGS84Test() {
|
||||||
PlanetModel planetModel = PlanetModel.WGS84;
|
PlanetModel planetModel = PlanetModel.WGS84;
|
||||||
RandomGeo3dShapeGenerator generator = new RandomGeo3dShapeGenerator();
|
GeoPoint center = randomGeoPoint(planetModel);
|
||||||
GeoPoint center = generator.randomGeoPoint(planetModel);
|
|
||||||
double radius = random().nextDouble() * Math.PI;
|
double radius = random().nextDouble() * Math.PI;
|
||||||
checkBearingPoint(planetModel, center, radius, 0);
|
checkBearingPoint(planetModel, center, radius, 0);
|
||||||
checkBearingPoint(planetModel, center, radius, 0.5 * Math.PI);
|
checkBearingPoint(planetModel, center, radius, 0.5 * Math.PI);
|
||||||
|
@ -197,7 +199,8 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
|
||||||
@Repeat(iterations = 100)
|
@Repeat(iterations = 100)
|
||||||
public void testRandomLUCENE8054() {
|
public void testRandomLUCENE8054() {
|
||||||
PlanetModel planetModel = randomPlanetModel();
|
PlanetModel planetModel = randomPlanetModel();
|
||||||
GeoCircle circle1 = (GeoCircle) randomGeoAreaShape(EXACT_CIRCLE, planetModel);
|
GeoCircle circle1 =
|
||||||
|
(GeoCircle) randomGeoAreaShape(RandomGeo3dShapeGenerator.EXACT_CIRCLE, planetModel);
|
||||||
// new radius, a bit smaller than the generated one!
|
// new radius, a bit smaller than the generated one!
|
||||||
double radius = circle1.getRadius() * (1 - 0.01 * random().nextDouble());
|
double radius = circle1.getRadius() * (1 - 0.01 * random().nextDouble());
|
||||||
// circle with same center and new radius
|
// circle with same center and new radius
|
||||||
|
|
|
@ -16,14 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Test basic plane functionality. */
|
/** Test basic plane functionality. */
|
||||||
public class TestGeoModel {
|
public class TestGeoModel extends LuceneTestCase {
|
||||||
|
|
||||||
protected static final PlanetModel scaledModel = new PlanetModel(1.2, 1.5);
|
protected static final PlanetModel scaledModel = new PlanetModel(1.2, 1.5);
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Test basic plane functionality. */
|
/** Test basic plane functionality. */
|
||||||
public class TestPlane {
|
public class TestPlane extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdenticalPlanes() {
|
public void testIdenticalPlanes() {
|
||||||
|
|
|
@ -17,15 +17,17 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Test to check Serialization */
|
/** Test to check Serialization */
|
||||||
public class TestRandomBinaryCodec extends RandomGeo3dShapeGenerator {
|
public class TestRandomBinaryCodec extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Repeat(iterations = 10)
|
@Repeat(iterations = 10)
|
||||||
public void testRandomPointCodec() throws IOException {
|
public void testRandomPointCodec() throws IOException {
|
||||||
|
|
|
@ -16,15 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.generators.BiasedNumbers;
|
import com.carrotsearch.randomizedtesting.generators.BiasedNumbers;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Random test for polygons. */
|
/** Random test for polygons. */
|
||||||
public class TestRandomGeoPolygon extends RandomGeo3dShapeGenerator {
|
public class TestRandomGeoPolygon extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRandomLUCENE8157() {
|
public void testRandomLUCENE8157() {
|
||||||
final PlanetModel planetModel = randomPlanetModel();
|
final PlanetModel planetModel = randomPlanetModel();
|
||||||
|
|
|
@ -17,11 +17,13 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
|
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Random test to check relationship between GeoAreaShapes and GeoShapes. */
|
/** Random test to check relationship between GeoAreaShapes and GeoShapes. */
|
||||||
public class TestRandomGeoShapeRelationship extends RandomGeo3dShapeGenerator {
|
public class TestRandomGeoShapeRelationship extends LuceneTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for WITHIN points. We build a WITHIN shape with respect the geoAreaShape and create a
|
* Test for WITHIN points. We build a WITHIN shape with respect the geoAreaShape and create a
|
||||||
* point WITHIN the shape. The resulting shape should be WITHIN the original shape.
|
* point WITHIN the shape. The resulting shape should be WITHIN the original shape.
|
||||||
|
|
|
@ -17,13 +17,16 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
|
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Random test for planes. */
|
/** Random test for planes. */
|
||||||
public class TestRandomPlane extends RandomGeo3dShapeGenerator {
|
public class TestRandomPlane extends LuceneTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Repeat(iterations = 10)
|
@Repeat(iterations = 10)
|
||||||
|
|
|
@ -17,19 +17,17 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check relationship between polygon and GeoShapes of basic polygons. Normally we construct the
|
* Check relationship between polygon and GeoShapes of basic polygons. Normally we construct the
|
||||||
* convex, concave counterpart and the convex polygon as a complex polygon.
|
* convex, concave counterpart and the convex polygon as a complex polygon.
|
||||||
*/
|
*/
|
||||||
public class TestSimpleGeoPolygonRelationships {
|
public class TestSimpleGeoPolygonRelationships extends LuceneTestCase {
|
||||||
|
|
||||||
/** Test with two shapes with no crossing edges and no points in common in convex case. */
|
/** Test with two shapes with no crossing edges and no points in common in convex case. */
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
|
|
||||||
package org.apache.lucene.spatial3d.geom;
|
package org.apache.lucene.spatial3d.geom;
|
||||||
|
|
||||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomDouble;
|
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||||
|
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generating random Geo3dShapes. They can be generated under given constraints which are
|
* Class for generating random Geo3dShapes. They can be generated under given constraints which are
|
||||||
|
@ -34,7 +34,7 @@ import org.apache.lucene.util.LuceneTestCase;
|
||||||
* otherwise they are convex. Internally they can be created using GeoConvexPolygons and
|
* otherwise they are convex. Internally they can be created using GeoConvexPolygons and
|
||||||
* GeoConcavePolygons.
|
* GeoConcavePolygons.
|
||||||
*/
|
*/
|
||||||
public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
public final class RandomGeo3dShapeGenerator {
|
||||||
|
|
||||||
/* Max num of iterations to find right shape under given constrains */
|
/* Max num of iterations to find right shape under given constrains */
|
||||||
private static final int MAX_SHAPE_ITERATIONS = 20;
|
private static final int MAX_SHAPE_ITERATIONS = 20;
|
||||||
|
@ -59,13 +59,21 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
protected static final int CONVEX_SIMPLE_POLYGON = 500;
|
protected static final int CONVEX_SIMPLE_POLYGON = 500;
|
||||||
protected static final int CONCAVE_SIMPLE_POLYGON = 501;
|
protected static final int CONCAVE_SIMPLE_POLYGON = 501;
|
||||||
|
|
||||||
|
/** Static methods only. */
|
||||||
|
private RandomGeo3dShapeGenerator() {}
|
||||||
|
|
||||||
|
/** @return Returns a private-use random forked from the current {@link RandomizedContext}. */
|
||||||
|
private static Random random() {
|
||||||
|
return new Random(RandomizedContext.current().getRandom().nextLong());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that returns a random generated Planet model from the supported Planet models. currently
|
* Method that returns a random generated Planet model from the supported Planet models. currently
|
||||||
* SPHERE and WGS84
|
* SPHERE and WGS84
|
||||||
*
|
*
|
||||||
* @return a random generated Planet model
|
* @return a random generated Planet model
|
||||||
*/
|
*/
|
||||||
public PlanetModel randomPlanetModel() {
|
public static PlanetModel randomPlanetModel() {
|
||||||
final int shapeType = random().nextInt(2);
|
final int shapeType = random().nextInt(2);
|
||||||
switch (shapeType) {
|
switch (shapeType) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -86,7 +94,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return a random generated shape code
|
* @return a random generated shape code
|
||||||
*/
|
*/
|
||||||
public int randomShapeType() {
|
public static int randomShapeType() {
|
||||||
return random().nextInt(12);
|
return random().nextInt(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +106,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return a random generated polygon code
|
* @return a random generated polygon code
|
||||||
*/
|
*/
|
||||||
public int randomGeoAreaShapeType() {
|
public static int randomGeoAreaShapeType() {
|
||||||
return random().nextInt(12);
|
return random().nextInt(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +115,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return a random generated convex shape code
|
* @return a random generated convex shape code
|
||||||
*/
|
*/
|
||||||
public int randomConvexShapeType() {
|
public static int randomConvexShapeType() {
|
||||||
int shapeType = randomShapeType();
|
int shapeType = randomShapeType();
|
||||||
while (isConcave(shapeType)) {
|
while (isConcave(shapeType)) {
|
||||||
shapeType = randomShapeType();
|
shapeType = randomShapeType();
|
||||||
|
@ -120,7 +128,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return a random generated concave shape code
|
* @return a random generated concave shape code
|
||||||
*/
|
*/
|
||||||
public int randomConcaveShapeType() {
|
public static int randomConcaveShapeType() {
|
||||||
int shapeType = randomShapeType();
|
int shapeType = randomShapeType();
|
||||||
while (!isConcave(shapeType)) {
|
while (!isConcave(shapeType)) {
|
||||||
shapeType = randomShapeType();
|
shapeType = randomShapeType();
|
||||||
|
@ -133,7 +141,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return true if the shape represented by the code is concave
|
* @return true if the shape represented by the code is concave
|
||||||
*/
|
*/
|
||||||
public boolean isConcave(int shapeType) {
|
public static boolean isConcave(int shapeType) {
|
||||||
return (shapeType == CONCAVE_POLYGON);
|
return (shapeType == CONCAVE_POLYGON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +150,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return an empty Constraints object
|
* @return an empty Constraints object
|
||||||
*/
|
*/
|
||||||
public Constraints getEmptyConstraint() {
|
public static Constraints getEmptyConstraint() {
|
||||||
return new Constraints();
|
return new Constraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +160,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param planetModel The planet model.
|
* @param planetModel The planet model.
|
||||||
* @return The random generated GeoPoint.
|
* @return The random generated GeoPoint.
|
||||||
*/
|
*/
|
||||||
public GeoPoint randomGeoPoint(PlanetModel planetModel) {
|
public static GeoPoint randomGeoPoint(PlanetModel planetModel) {
|
||||||
GeoPoint point = null;
|
GeoPoint point = null;
|
||||||
while (point == null) {
|
while (point == null) {
|
||||||
point = randomGeoPoint(planetModel, getEmptyConstraint());
|
point = randomGeoPoint(planetModel, getEmptyConstraint());
|
||||||
|
@ -168,14 +176,14 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPoint.
|
* @return The random generated GeoPoint.
|
||||||
*/
|
*/
|
||||||
public GeoPoint randomGeoPoint(PlanetModel planetModel, Constraints constraints) {
|
public static GeoPoint randomGeoPoint(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_POINT_ITERATIONS) {
|
while (iterations < MAX_POINT_ITERATIONS) {
|
||||||
double lat = randomDouble() * Math.PI / 2;
|
double lat = RandomizedTest.randomDouble() * Math.PI / 2;
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
lat = (-1) * lat;
|
lat = (-1) * lat;
|
||||||
}
|
}
|
||||||
double lon = randomDouble() * Math.PI;
|
double lon = RandomizedTest.randomDouble() * Math.PI;
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
lon = (-1) * lon;
|
lon = (-1) * lon;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +203,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param planetModel The planet model.
|
* @param planetModel The planet model.
|
||||||
* @return The random generated GeoAreaShape.
|
* @return The random generated GeoAreaShape.
|
||||||
*/
|
*/
|
||||||
public GeoAreaShape randomGeoAreaShape(int shapeType, PlanetModel planetModel) {
|
public static GeoAreaShape randomGeoAreaShape(int shapeType, PlanetModel planetModel) {
|
||||||
GeoAreaShape geoAreaShape = null;
|
GeoAreaShape geoAreaShape = null;
|
||||||
while (geoAreaShape == null) {
|
while (geoAreaShape == null) {
|
||||||
geoAreaShape = randomGeoAreaShape(shapeType, planetModel, new Constraints());
|
geoAreaShape = randomGeoAreaShape(shapeType, planetModel, new Constraints());
|
||||||
|
@ -212,7 +220,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoAreaShape.
|
* @return The random generated GeoAreaShape.
|
||||||
*/
|
*/
|
||||||
public GeoAreaShape randomGeoAreaShape(
|
public static GeoAreaShape randomGeoAreaShape(
|
||||||
int shapeType, PlanetModel planetModel, Constraints constraints) {
|
int shapeType, PlanetModel planetModel, Constraints constraints) {
|
||||||
return (GeoAreaShape) randomGeoShape(shapeType, planetModel, constraints);
|
return (GeoAreaShape) randomGeoShape(shapeType, planetModel, constraints);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +232,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param planetModel The planet model.
|
* @param planetModel The planet model.
|
||||||
* @return The random generated GeoShape.
|
* @return The random generated GeoShape.
|
||||||
*/
|
*/
|
||||||
public GeoShape randomGeoShape(int shapeType, PlanetModel planetModel) {
|
public static GeoShape randomGeoShape(int shapeType, PlanetModel planetModel) {
|
||||||
GeoShape geoShape = null;
|
GeoShape geoShape = null;
|
||||||
while (geoShape == null) {
|
while (geoShape == null) {
|
||||||
geoShape = randomGeoShape(shapeType, planetModel, new Constraints());
|
geoShape = randomGeoShape(shapeType, planetModel, new Constraints());
|
||||||
|
@ -241,7 +249,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoShape.
|
* @return The random generated GeoShape.
|
||||||
*/
|
*/
|
||||||
public GeoShape randomGeoShape(int shapeType, PlanetModel planetModel, Constraints constraints) {
|
public static GeoShape randomGeoShape(
|
||||||
|
int shapeType, PlanetModel planetModel, Constraints constraints) {
|
||||||
switch (shapeType) {
|
switch (shapeType) {
|
||||||
case CONVEX_POLYGON:
|
case CONVEX_POLYGON:
|
||||||
{
|
{
|
||||||
|
@ -312,7 +321,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPointShape.
|
* @return The random generated GeoPointShape.
|
||||||
*/
|
*/
|
||||||
private GeoPointShape point(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPointShape point(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -344,7 +353,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoCircle.
|
* @return The random generated GeoCircle.
|
||||||
*/
|
*/
|
||||||
private GeoCircle circle(PlanetModel planetModel, Constraints constraints) {
|
private static GeoCircle circle(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -377,7 +386,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoCircle.
|
* @return The random generated GeoCircle.
|
||||||
*/
|
*/
|
||||||
private GeoCircle exactCircle(PlanetModel planetModel, Constraints constraints) {
|
private static GeoCircle exactCircle(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -411,7 +420,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoBBox.
|
* @return The random generated GeoBBox.
|
||||||
*/
|
*/
|
||||||
private GeoBBox rectangle(PlanetModel planetModel, Constraints constraints) {
|
private static GeoBBox rectangle(PlanetModel planetModel, Constraints constraints) {
|
||||||
|
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
|
@ -451,7 +460,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated degenerated GeoPath.
|
* @return The random generated degenerated GeoPath.
|
||||||
*/
|
*/
|
||||||
private GeoPath line(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPath line(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -483,7 +492,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPath.
|
* @return The random generated GeoPath.
|
||||||
*/
|
*/
|
||||||
private GeoPath path(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPath path(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -516,7 +525,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoCompositeMembershipShape.
|
* @return The random generated GeoCompositeMembershipShape.
|
||||||
*/
|
*/
|
||||||
private GeoCompositeAreaShape collection(PlanetModel planetModel, Constraints constraints) {
|
private static GeoCompositeAreaShape collection(
|
||||||
|
PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -544,7 +554,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon convexPolygon(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon convexPolygon(PlanetModel planetModel, Constraints constraints) {
|
||||||
int vertexCount = random().nextInt(4) + 3;
|
int vertexCount = random().nextInt(4) + 3;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
|
@ -575,7 +585,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon convexPolygonWithHoles(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon convexPolygonWithHoles(
|
||||||
|
PlanetModel planetModel, Constraints constraints) {
|
||||||
int vertexCount = random().nextInt(4) + 3;
|
int vertexCount = random().nextInt(4) + 3;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
|
@ -633,7 +644,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param pointConstraints The given constraints that a point must comply.
|
* @param pointConstraints The given constraints that a point must comply.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private List<GeoPolygon> concavePolygonHoles(
|
private static List<GeoPolygon> concavePolygonHoles(
|
||||||
PlanetModel planetModel,
|
PlanetModel planetModel,
|
||||||
GeoPolygon polygon,
|
GeoPolygon polygon,
|
||||||
Constraints holeConstraints,
|
Constraints holeConstraints,
|
||||||
|
@ -681,7 +692,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon concavePolygon(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon concavePolygon(PlanetModel planetModel, Constraints constraints) {
|
||||||
|
|
||||||
int vertexCount = random().nextInt(4) + 3;
|
int vertexCount = random().nextInt(4) + 3;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
|
@ -715,7 +726,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon concavePolygonWithHoles(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon concavePolygonWithHoles(
|
||||||
|
PlanetModel planetModel, Constraints constraints) {
|
||||||
int vertexCount = random().nextInt(4) + 3;
|
int vertexCount = random().nextInt(4) + 3;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
|
@ -770,7 +782,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon complexPolygon(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon complexPolygon(PlanetModel planetModel, Constraints constraints) {
|
||||||
int polygonsCount = random().nextInt(2) + 1;
|
int polygonsCount = random().nextInt(2) + 1;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
|
@ -807,7 +819,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon simpleConvexPolygon(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon simpleConvexPolygon(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -838,7 +850,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated GeoPolygon.
|
* @return The random generated GeoPolygon.
|
||||||
*/
|
*/
|
||||||
private GeoPolygon concaveSimplePolygon(PlanetModel planetModel, Constraints constraints) {
|
private static GeoPolygon concaveSimplePolygon(PlanetModel planetModel, Constraints constraints) {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (iterations < MAX_SHAPE_ITERATIONS) {
|
while (iterations < MAX_SHAPE_ITERATIONS) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
@ -870,7 +882,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param constraints The given constraints.
|
* @param constraints The given constraints.
|
||||||
* @return The random generated List of GeoPoints.
|
* @return The random generated List of GeoPoints.
|
||||||
*/
|
*/
|
||||||
private List<GeoPoint> points(int count, PlanetModel planetModel, Constraints constraints) {
|
private static List<GeoPoint> points(
|
||||||
|
int count, PlanetModel planetModel, Constraints constraints) {
|
||||||
List<GeoPoint> geoPoints = new ArrayList<>(count);
|
List<GeoPoint> geoPoints = new ArrayList<>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
GeoPoint point = randomGeoPoint(planetModel, constraints);
|
GeoPoint point = randomGeoPoint(planetModel, constraints);
|
||||||
|
@ -889,7 +902,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param shape The polygon to check.
|
* @param shape The polygon to check.
|
||||||
* @return True if the polygon contains antipodal points.
|
* @return True if the polygon contains antipodal points.
|
||||||
*/
|
*/
|
||||||
private boolean isConcave(PlanetModel planetModel, GeoPolygon shape) {
|
private static boolean isConcave(PlanetModel planetModel, GeoPolygon shape) {
|
||||||
return (shape.isWithin(planetModel.NORTH_POLE) && shape.isWithin(planetModel.SOUTH_POLE))
|
return (shape.isWithin(planetModel.NORTH_POLE) && shape.isWithin(planetModel.SOUTH_POLE))
|
||||||
|| (shape.isWithin(planetModel.MAX_X_POLE) && shape.isWithin(planetModel.MIN_X_POLE))
|
|| (shape.isWithin(planetModel.MAX_X_POLE) && shape.isWithin(planetModel.MIN_X_POLE))
|
||||||
|| (shape.isWithin(planetModel.MAX_Y_POLE) && shape.isWithin(planetModel.MIN_Y_POLE));
|
|| (shape.isWithin(planetModel.MAX_Y_POLE) && shape.isWithin(planetModel.MIN_Y_POLE));
|
||||||
|
@ -903,7 +916,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param shape The polygon to check.
|
* @param shape The polygon to check.
|
||||||
* @return True if the polygon dies not contains antipodal points.
|
* @return True if the polygon dies not contains antipodal points.
|
||||||
*/
|
*/
|
||||||
private boolean isConvex(PlanetModel planetModel, GeoPolygon shape) {
|
private static boolean isConvex(PlanetModel planetModel, GeoPolygon shape) {
|
||||||
return !isConcave(planetModel, shape);
|
return !isConcave(planetModel, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,8 +925,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
*
|
*
|
||||||
* @return the cutoff angle.
|
* @return the cutoff angle.
|
||||||
*/
|
*/
|
||||||
private double randomCutoffAngle() {
|
private static double randomCutoffAngle() {
|
||||||
return randomDouble() * Math.PI;
|
return RandomizedTest.randomDouble() * Math.PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -922,7 +935,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* @param points The points to order.
|
* @param points The points to order.
|
||||||
* @return The list of ordered points anti-clockwise.
|
* @return The list of ordered points anti-clockwise.
|
||||||
*/
|
*/
|
||||||
protected List<GeoPoint> orderPoints(List<GeoPoint> points) {
|
protected static List<GeoPoint> orderPoints(List<GeoPoint> points) {
|
||||||
double x = 0;
|
double x = 0;
|
||||||
double y = 0;
|
double y = 0;
|
||||||
double z = 0;
|
double z = 0;
|
||||||
|
@ -964,7 +977,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
|
||||||
* Class that holds the constraints that are given to build shapes. It consists in a list of
|
* Class that holds the constraints that are given to build shapes. It consists in a list of
|
||||||
* GeoAreaShapes and relationships the new shape needs to satisfy.
|
* GeoAreaShapes and relationships the new shape needs to satisfy.
|
||||||
*/
|
*/
|
||||||
class Constraints extends HashMap<GeoAreaShape, Integer> {
|
static class Constraints extends HashMap<GeoAreaShape, Integer> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the shape is valid under the constraints.
|
* Check if the shape is valid under the constraints.
|
Loading…
Reference in New Issue