mirror of https://github.com/apache/lucene.git
LUCENE-8369: Remove obsolete spatial module
This commit is contained in:
parent
35d8e3de6d
commit
78655239c5
|
@ -38,7 +38,6 @@
|
|||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/queryparser/queryparser.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/replicator/replicator.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/sandbox/sandbox.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/spatial/spatial.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/spatial-extras/spatial-extras.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/spatial3d/spatial3d.iml" />
|
||||
<module group="Lucene/Other" filepath="$PROJECT_DIR$/lucene/suggest/suggest.iml" />
|
||||
|
|
|
@ -212,14 +212,6 @@
|
|||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||
<patterns><pattern testClass=".*\.Test[^.]*|.*\.[^.]*Test" /></patterns>
|
||||
</configuration>
|
||||
<configuration default="false" name="Module spatial" type="JUnit" factoryName="JUnit">
|
||||
<module name="spatial" />
|
||||
<option name="TEST_OBJECT" value="pattern" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/lucene/spatial" />
|
||||
<option name="VM_PARAMETERS" value="-ea -DtempDir=temp" />
|
||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||
<patterns><pattern testClass=".*\.Test[^.]*|.*\.[^.]*Test" /></patterns>
|
||||
</configuration>
|
||||
<configuration default="false" name="Module spatial-extras" type="JUnit" factoryName="JUnit">
|
||||
<module name="spatial-extras" />
|
||||
<option name="TEST_OBJECT" value="pattern" />
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/../../idea-build/lucene/spatial/classes/java" />
|
||||
<output-test url="file://$MODULE_DIR$/../../idea-build/lucene/spatial/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
|
||||
<orderEntry type="module" scope="TEST" module-name="lucene-test-framework" />
|
||||
<orderEntry type="module" module-name="lucene-core" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -60,7 +60,6 @@
|
|||
<module>queryparser</module>
|
||||
<module>replicator</module>
|
||||
<module>sandbox</module>
|
||||
<module>spatial</module>
|
||||
<module>spatial-extras</module>
|
||||
<module>spatial3d</module>
|
||||
<module>suggest</module>
|
||||
|
|
|
@ -1,75 +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.
|
||||
-->
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-parent</artifactId>
|
||||
<version>@version@</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-spatial</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Lucene Spatial</name>
|
||||
<description>
|
||||
Geospatial Indexing and Query for Apache Lucene
|
||||
</description>
|
||||
<properties>
|
||||
<module-directory>lucene/spatial</module-directory>
|
||||
<relative-top-level>../../..</relative-top-level>
|
||||
<module-path>${relative-top-level}/${module-directory}</module-path>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- lucene-test-framework dependency must be declared before lucene-core -->
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-test-framework</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@lucene-spatial.internal.dependencies@
|
||||
@lucene-spatial.external.dependencies@
|
||||
@lucene-spatial.internal.test.dependencies@
|
||||
@lucene-spatial.external.test.dependencies@
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${module-path}/src/java</sourceDirectory>
|
||||
<testSourceDirectory>${module-path}/src/test</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${module-path}/src/test-files</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -621,7 +621,7 @@ def verifyUnpacked(java, project, artifact, unpackPath, gitRevision, version, te
|
|||
|
||||
if project == 'lucene':
|
||||
# TODO: clean this up to not be a list of modules that we must maintain
|
||||
extras = ('analysis', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial', 'spatial-extras', 'spatial3d', 'suggest', 'test-framework', 'licenses')
|
||||
extras = ('analysis', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial-extras', 'spatial3d', 'suggest', 'test-framework', 'licenses')
|
||||
if isSrc:
|
||||
extras += ('build.xml', 'common-build.xml', 'module-build.xml', 'top-level-ivy-settings.xml', 'default-nested-ivy-settings.xml', 'ivy-versions.properties', 'ivy-ignore-conflicts.properties', 'version.properties', 'tools', 'site')
|
||||
else:
|
||||
|
|
|
@ -35,7 +35,6 @@ configure(rootProject) {
|
|||
":lucene:queryparser",
|
||||
":lucene:replicator",
|
||||
":lucene:sandbox",
|
||||
":lucene:spatial",
|
||||
":lucene:spatial-extras",
|
||||
":lucene:spatial3d",
|
||||
":lucene:suggest",
|
||||
|
|
|
@ -91,6 +91,8 @@ API Changes
|
|||
yield Passages sized a little different due to the fact that the sizing pivot is now the center of the first match and
|
||||
not its left edge.
|
||||
|
||||
* LUCENE-8369: Remove obsolete spatial module. (Nick Knize, David Smiley)
|
||||
|
||||
New Features
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -182,7 +182,6 @@
|
|||
<!-- queries: problems -->
|
||||
<!-- queryparser: problems -->
|
||||
<!-- sandbox: problems -->
|
||||
<check-missing-javadocs dir="build/docs/spatial" level="method"/>
|
||||
<!-- spatial-extras: problems -->
|
||||
<check-missing-javadocs dir="build/docs/suggest" level="method"/>
|
||||
<!-- test-framework: problems -->
|
||||
|
|
|
@ -653,28 +653,6 @@
|
|||
<property name="spatial3d-javadocs.uptodate" value="true"/>
|
||||
</target>
|
||||
|
||||
<property name="spatial.jar" value="${common.dir}/build/spatial/lucene-spatial-${version}.jar"/>
|
||||
<target name="check-spatial-uptodate" unless="spatial.uptodate">
|
||||
<module-uptodate name="spatial" jarfile="${spatial.jar}" property="spatial.uptodate"/>
|
||||
</target>
|
||||
<target name="jar-spatial" unless="spatial.uptodate" depends="check-spatial-uptodate">
|
||||
<ant dir="${common.dir}/spatial" target="jar-core" inheritAll="false">
|
||||
<propertyset refid="uptodate.and.compiled.properties"/>
|
||||
</ant>
|
||||
<property name="spatial.uptodate" value="true"/>
|
||||
</target>
|
||||
|
||||
<property name="spatial-javadoc.jar" value="${common.dir}/build/spatial/lucene-spatial-${version}-javadoc.jar"/>
|
||||
<target name="check-spatial-javadocs-uptodate" unless="spatial-javadocs.uptodate">
|
||||
<module-uptodate name="spatial" jarfile="${spatial-javadoc.jar}" property="spatial-javadocs.uptodate"/>
|
||||
</target>
|
||||
<target name="javadocs-spatial" unless="spatial-javadocs.uptodate" depends="check-spatial-javadocs-uptodate">
|
||||
<ant dir="${common.dir}/spatial" target="javadocs" inheritAll="false">
|
||||
<propertyset refid="uptodate.and.compiled.properties"/>
|
||||
</ant>
|
||||
<property name="spatial-javadocs.uptodate" value="true"/>
|
||||
</target>
|
||||
|
||||
<property name="spatial-extras.jar" value="${common.dir}/build/spatial-extras/lucene-spatial-extras-${version}.jar"/>
|
||||
<target name="check-spatial-extras-uptodate" unless="spatial-extras.uptodate">
|
||||
<module-uptodate name="spatial-extras" jarfile="${spatial-extras.jar}" property="spatial-extras.uptodate"/>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<p>
|
||||
The spatial-extras module, new to Lucene 6.5, is the new home for the original
|
||||
lucene <a href="../spatial/overview-summary.html">spatial</a> module.
|
||||
lucene spatial module.
|
||||
The principle interface to this module is a {@link org.apache.lucene.spatial.SpatialStrategy}
|
||||
which encapsulates an approach to indexing and searching
|
||||
based on shapes. Different Strategies have different features and
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
apply plugin: 'java-library'
|
||||
|
||||
dependencies {
|
||||
api project(':lucene:core')
|
||||
testImplementation project(':lucene:test-framework')
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.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.
|
||||
-->
|
||||
<project name="spatial" default="default">
|
||||
<description>
|
||||
Geospatial search
|
||||
</description>
|
||||
|
||||
<import file="../module-build.xml"/>
|
||||
|
||||
</project>
|
|
@ -1,21 +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.
|
||||
-->
|
||||
<ivy-module version="2.0" xmlns:maven="http://ant.apache.org/ivy/maven">
|
||||
<info organisation="org.apache.lucene" module="spatial"/>
|
||||
</ivy-module>
|
|
@ -1,21 +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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lucene spatial search
|
||||
*/
|
||||
package org.apache.lucene.spatial;
|
|
@ -1,75 +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.
|
||||
*/
|
||||
package org.apache.lucene.spatial.util;
|
||||
|
||||
/**
|
||||
* Reusable geo-relation utility methods
|
||||
*/
|
||||
public class GeoRelationUtils {
|
||||
|
||||
// No instance:
|
||||
private GeoRelationUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a bbox (defined by minLat, maxLat, minLon, maxLon) contains the provided point (defined by lat, lon)
|
||||
* NOTE: this is a basic method that does not handle dateline or pole crossing. Unwrapping must be done before
|
||||
* calling this method.
|
||||
*/
|
||||
public static boolean pointInRectPrecise(final double lat, final double lon,
|
||||
final double minLat, final double maxLat,
|
||||
final double minLon, final double maxLon) {
|
||||
return lat >= minLat && lat <= maxLat && lon >= minLon && lon <= maxLon;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// Rectangle relations
|
||||
/////////////////////////
|
||||
|
||||
/**
|
||||
* Computes whether two rectangles are disjoint
|
||||
*/
|
||||
private static boolean rectDisjoint(final double aMinLat, final double aMaxLat, final double aMinLon, final double aMaxLon,
|
||||
final double bMinLat, final double bMaxLat, final double bMinLon, final double bMaxLon) {
|
||||
return (aMaxLon < bMinLon || aMinLon > bMaxLon || aMaxLat < bMinLat || aMinLat > bMaxLat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes whether the first (a) rectangle is wholly within another (b) rectangle (shared boundaries allowed)
|
||||
*/
|
||||
public static boolean rectWithin(final double aMinLat, final double aMaxLat, final double aMinLon, final double aMaxLon,
|
||||
final double bMinLat, final double bMaxLat, final double bMinLon, final double bMaxLon) {
|
||||
return !(aMinLon < bMinLon || aMinLat < bMinLat || aMaxLon > bMaxLon || aMaxLat > bMaxLat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes whether two rectangles cross
|
||||
*/
|
||||
public static boolean rectCrosses(final double aMinLat, final double aMaxLat, final double aMinLon, final double aMaxLon,
|
||||
final double bMinLat, final double bMaxLat, final double bMinLon, final double bMaxLon) {
|
||||
return !(rectDisjoint(aMinLat, aMaxLat, aMinLon, aMaxLon, bMinLat, bMaxLat, bMinLon, bMaxLon) ||
|
||||
rectWithin(aMinLat, aMaxLat, aMinLon, aMaxLon, bMinLat, bMaxLat, bMinLon, bMaxLon));
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes whether a rectangle intersects another rectangle (crosses, within, touching, etc)
|
||||
*/
|
||||
public static boolean rectIntersects(final double aMinLat, final double aMaxLat, final double aMinLon, final double aMaxLon,
|
||||
final double bMinLat, final double bMaxLat, final double bMinLon, final double bMaxLon) {
|
||||
return !((aMaxLon < bMinLon || aMinLon > bMaxLon || aMaxLat < bMinLat || aMinLat > bMaxLat));
|
||||
}
|
||||
}
|
|
@ -1,103 +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.
|
||||
*/
|
||||
package org.apache.lucene.spatial.util;
|
||||
|
||||
import org.apache.lucene.geo.GeoEncodingUtils;
|
||||
import org.apache.lucene.util.BitUtil;
|
||||
|
||||
import static org.apache.lucene.geo.GeoUtils.checkLatitude;
|
||||
import static org.apache.lucene.geo.GeoUtils.checkLongitude;
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.encodeLatitude;
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.encodeLatitudeCeil;
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.encodeLongitude;
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.encodeLongitudeCeil;
|
||||
|
||||
/**
|
||||
* Quantizes lat/lon points and bit interleaves them into a binary morton code
|
||||
* in the range of 0x00000000... : 0xFFFFFFFF...
|
||||
* https://en.wikipedia.org/wiki/Z-order_curve
|
||||
*
|
||||
* This is useful for bitwise operations in raster space
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class MortonEncoder {
|
||||
|
||||
private MortonEncoder() {} // no instance
|
||||
|
||||
/**
|
||||
* Main encoding method to quantize lat/lon points and bit interleave them into a binary morton code
|
||||
* in the range of 0x00000000... : 0xFFFFFFFF...
|
||||
*
|
||||
* @param latitude latitude value: must be within standard +/-90 coordinate bounds.
|
||||
* @param longitude longitude value: must be within standard +/-180 coordinate bounds.
|
||||
* @return bit interleaved encoded values as a 64-bit {@code long}
|
||||
* @throws IllegalArgumentException if latitude or longitude is out of bounds
|
||||
*/
|
||||
public static final long encode(double latitude, double longitude) {
|
||||
checkLatitude(latitude);
|
||||
checkLongitude(longitude);
|
||||
// encode lat/lon flipping the sign bit so negative ints sort before positive ints
|
||||
final int latEnc = encodeLatitude(latitude) ^ 0x80000000;
|
||||
final int lonEnc = encodeLongitude(longitude) ^ 0x80000000;
|
||||
return BitUtil.interleave(lonEnc, latEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quantizes lat/lon points and bit interleaves them into a sortable morton code
|
||||
* ranging from 0x00 : 0xFF...
|
||||
* https://en.wikipedia.org/wiki/Z-order_curve
|
||||
* This is useful for bitwise operations in raster space
|
||||
* @param latitude latitude value: must be within standard +/-90 coordinate bounds.
|
||||
* @param longitude longitude value: must be within standard +/-180 coordinate bounds.
|
||||
* @return bit interleaved encoded values as a 64-bit {@code long}
|
||||
* @throws IllegalArgumentException if latitude or longitude is out of bounds
|
||||
*/
|
||||
public static final long encodeCeil(double latitude, double longitude) {
|
||||
checkLatitude(latitude);
|
||||
checkLongitude(longitude);
|
||||
// encode lat/lon flipping the sign bit so negative ints sort before positive ints
|
||||
final int latEnc = encodeLatitudeCeil(latitude) ^ 0x80000000;
|
||||
final int lonEnc = encodeLongitudeCeil(longitude) ^ 0x80000000;
|
||||
return BitUtil.interleave(lonEnc, latEnc);
|
||||
}
|
||||
|
||||
/** decode latitude value from morton encoded geo point */
|
||||
public static final double decodeLatitude(final long hash) {
|
||||
// decode lat/lon flipping the sign bit so negative ints sort before positive ints
|
||||
return GeoEncodingUtils.decodeLatitude((int) BitUtil.deinterleave(hash >>> 1) ^ 0x80000000);
|
||||
}
|
||||
|
||||
/** decode longitude value from morton encoded geo point */
|
||||
public static final double decodeLongitude(final long hash) {
|
||||
// decode lat/lon flipping the sign bit so negative ints sort before positive ints
|
||||
return GeoEncodingUtils.decodeLongitude((int) BitUtil.deinterleave(hash) ^ 0x80000000);
|
||||
}
|
||||
|
||||
/** Converts a long value into a full 64 bit string (useful for debugging) */
|
||||
public static String geoTermToString(long term) {
|
||||
StringBuilder s = new StringBuilder(64);
|
||||
final int numberOfLeadingZeros = Long.numberOfLeadingZeros(term);
|
||||
for (int i = 0; i < numberOfLeadingZeros; i++) {
|
||||
s.append('0');
|
||||
}
|
||||
if (term != 0) {
|
||||
s.append(Long.toBinaryString(term));
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
}
|
|
@ -1,21 +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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Various spatial utilities.
|
||||
*/
|
||||
package org.apache.lucene.spatial.util;
|
|
@ -1,33 +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.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Apache Lucene Spatial Module</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>The Spatial Module for Apache Lucene</h1>
|
||||
<p>
|
||||
APIs for geospatial indexing and querying. Dependencies for the spatial module are
|
||||
restricted to inner lucene modules only. That is, no third-party dependencies
|
||||
are allowed. The intent is to keep this module free of any integration or
|
||||
licensing issues that might arise as a result of depending on an external library.
|
||||
For adding or leveraging spatial features that require third-party libraries see
|
||||
the <a href="../spatial-extras/overview-summary.html">spatial-extras</a> package.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,108 +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.
|
||||
*/
|
||||
package org.apache.lucene.spatial.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude;
|
||||
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude;
|
||||
import static org.apache.lucene.spatial.util.MortonEncoder.decodeLatitude;
|
||||
import static org.apache.lucene.spatial.util.MortonEncoder.decodeLongitude;
|
||||
import static org.apache.lucene.spatial.util.MortonEncoder.encode;
|
||||
import static org.apache.lucene.spatial.util.MortonEncoder.encodeCeil;
|
||||
|
||||
import static org.apache.lucene.util.BitUtil.deinterleave;
|
||||
import static org.apache.lucene.util.BitUtil.interleave;
|
||||
|
||||
/**
|
||||
* Tests methods in {@link MortonEncoder}
|
||||
*/
|
||||
public class TestMortonEncoder extends LuceneTestCase {
|
||||
|
||||
public void testMortonEncoding() throws Exception {
|
||||
final long TRANSLATE = 1L << 31;
|
||||
final double LATITUDE_DECODE = 180.0D/(0x1L<<32);
|
||||
final double LONGITUDE_DECODE = 360.0D/(0x1L<<32);
|
||||
Random random = random();
|
||||
for(int i=0; i < 10000; ++i) {
|
||||
long encoded = random().nextLong();
|
||||
long encodedLat = deinterleave(encoded >>> 1);
|
||||
long encodedLon = deinterleave(encoded);
|
||||
double expectedLat = decodeLatitude((int)(encodedLat - TRANSLATE));
|
||||
double decodedLat = decodeLatitude(encoded);
|
||||
double expectedLon = decodeLongitude((int)(encodedLon - TRANSLATE));
|
||||
double decodedLon = decodeLongitude(encoded);
|
||||
assertEquals(expectedLat, decodedLat, 0.0D);
|
||||
assertEquals(expectedLon, decodedLon, 0.0D);
|
||||
// should round-trip
|
||||
assertEquals(encoded, encode(decodedLat, decodedLon));
|
||||
|
||||
// test within the range
|
||||
if (encoded != 0xFFFFFFFFFFFFFFFFL) {
|
||||
// this is the next representable value
|
||||
// all double values between [min .. max) should encode to the current integer
|
||||
// all double values between (min .. max] should encodeCeil to the next integer.
|
||||
double maxLat = expectedLat + LATITUDE_DECODE;
|
||||
encodedLat += 1;
|
||||
assertEquals(maxLat, decodeLatitude((int)(encodedLat - TRANSLATE)), 0.0D);
|
||||
double maxLon = expectedLon + LONGITUDE_DECODE;
|
||||
encodedLon += 1;
|
||||
assertEquals(maxLon, decodeLongitude((int)(encodedLon - TRANSLATE)), 0.0D);
|
||||
long encodedNext = encode(maxLat, maxLon);
|
||||
assertEquals(interleave((int)encodedLon, (int)encodedLat), encodedNext);
|
||||
|
||||
// first and last doubles in range that will be quantized
|
||||
double minEdgeLat = Math.nextUp(expectedLat);
|
||||
double minEdgeLon = Math.nextUp(expectedLon);
|
||||
long encodedMinEdge = encode(minEdgeLat, minEdgeLon);
|
||||
long encodedMinEdgeCeil = encodeCeil(minEdgeLat, minEdgeLon);
|
||||
double maxEdgeLat = Math.nextDown(maxLat);
|
||||
double maxEdgeLon = Math.nextDown(maxLon);
|
||||
long encodedMaxEdge = encode(maxEdgeLat, maxEdgeLon);
|
||||
long encodedMaxEdgeCeil = encodeCeil(maxEdgeLat, maxEdgeLon);
|
||||
|
||||
assertEquals(encodedLat - 1, deinterleave(encodedMinEdge >>> 1));
|
||||
assertEquals(encodedLat, deinterleave(encodedMinEdgeCeil >>> 1));
|
||||
assertEquals(encodedLon - 1, deinterleave(encodedMinEdge));
|
||||
assertEquals(encodedLon, deinterleave(encodedMinEdgeCeil));
|
||||
|
||||
assertEquals(encodedLat - 1, deinterleave(encodedMaxEdge >>> 1));
|
||||
assertEquals(encodedLat, deinterleave(encodedMaxEdgeCeil >>> 1));
|
||||
assertEquals(encodedLon - 1, deinterleave(encodedMaxEdge));
|
||||
assertEquals(encodedLon, deinterleave(encodedMaxEdgeCeil));
|
||||
|
||||
// check random values within the double range
|
||||
long minBitsLat = NumericUtils.doubleToSortableLong(minEdgeLat);
|
||||
long maxBitsLat = NumericUtils.doubleToSortableLong(maxEdgeLat);
|
||||
long minBitsLon = NumericUtils.doubleToSortableLong(minEdgeLon);
|
||||
long maxBitsLon = NumericUtils.doubleToSortableLong(maxEdgeLon);
|
||||
for (int j = 0; j < 100; j++) {
|
||||
double valueLat = NumericUtils.sortableLongToDouble(TestUtil.nextLong(random, minBitsLat, maxBitsLat));
|
||||
double valueLon = NumericUtils.sortableLongToDouble(TestUtil.nextLong(random, minBitsLon, maxBitsLon));
|
||||
// round down
|
||||
assertEquals(encoded, encode(valueLat, valueLon));
|
||||
// round up
|
||||
assertEquals(interleave((int)encodedLon, (int)encodedLat), encodeCeil(valueLat, valueLon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ include "lucene:queries"
|
|||
include "lucene:queryparser"
|
||||
include "lucene:replicator"
|
||||
include "lucene:sandbox"
|
||||
include "lucene:spatial"
|
||||
include "lucene:spatial-extras"
|
||||
include "lucene:spatial3d"
|
||||
include "lucene:suggest"
|
||||
|
|
Loading…
Reference in New Issue