Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,27 @@ public enum TransformFunctionType {
MAPVALUE("mapValue"),

// Special type for annotation based scalar functions
SCALAR("scalar");
SCALAR("scalar"),
// geo constructors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) Add an empty line in front, and capitalize the comment

ST_GEOG_FROM_TEXT("ST_GeogFromText"),
ST_GEOM_FROM_TEXT("ST_GeomFromText"),
ST_GEOG_FROM_WKB("ST_GeogFromWKB"),
ST_GEOM_FROM_WKB("ST_GeomFromWKB"),
ST_POINT("ST_Point"),
ST_POLYGON("ST_Polygon"),

// geo measurements
ST_AREA("ST_Area"),
ST_DISTANCE("ST_Distance"),
ST_GEOMETRY_TYPE("ST_GEOMETRY_TYPE"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ST_GEOMETRY_TYPE("ST_GEOMETRY_TYPE"),
ST_GEOMETRY_TYPE("ST_GeometryType"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a standard function to return the SRID of the geometry? (Identify whether it is geometry or geography)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it returns the type of the geometry as a string. EG: 'ST_Linestring', 'ST_Polygon','ST_MultiPolygon' etc


// geo outputs
ST_AS_BINARY("ST_AsBinary"),
ST_AS_TEXT("ST_AsText"),

// geo relationship
ST_CONTAINS("ST_Contains"),
ST_EQUALS("ST_Equals");
Comment thread
Jackie-Jiang marked this conversation as resolved.
private final String _name;

TransformFunctionType(String name) {
Expand Down
21 changes: 20 additions & 1 deletion pinot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>

<dependency>
<groupId>org.locationtech.jts</groupId>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Eclipse license ok to add? So far we have taken Apache/MIT/Gnu.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is okay to include.
Per https://www.apache.org/legal/resolved.html#category-a, Eclipse Distribution License 1.0 can be included. And JTS is dual-licensed under Eclipse Public License 2.0 and Eclipse Distribution License 1.0 (https://github.com/locationtech/jts#license)

<artifactId>jts-core</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.apache.pinot</groupId>
Expand Down Expand Up @@ -227,5 +234,17 @@
<artifactId>lucene-analyzers-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't include jmh in pinot-core, you can move the benchmark class to the pinot-perf package

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it to pinot-perf project.

<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* 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.pinot.core.geospatial;

/**
* The geometry type.
*/
public enum GeometryType {

POINT(false, "ST_Point"),
MULTI_POINT(true, "ST_MultiPoint"),
LINE_STRING(false, "ST_LineString"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/Geometry.html, there is another type LINEAR_RING. Should we include that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LINEAR_RING is a subtype of LINEAR_STRING

MULTI_LINE_STRING(true, "ST_MultiLineString"),
POLYGON(false, "ST_Polygon"),
MULTI_POLYGON(true, "ST_MultiPolygon"),
GEOMETRY_COLLECTION(true, "ST_GeomCollection");

private final boolean _multitype;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final boolean _multitype;
private final boolean _multiType;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) _multiType? (IDE identify multitype as typo)

private final String _name;

GeometryType(boolean multitype, String name) {
_multitype = multitype;
_name = name;
}

public boolean isMultitype() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems never used. How are you planning to use the multi-type info?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in this PR. It's useful in function like https://postgis.net/docs/ST_GeometryN.html

return _multitype;
}

public String getName() {
return _name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* 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.pinot.core.geospatial;

import com.google.common.base.Joiner;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.PrecisionModel;


/**
* Utility methods for the geometry.
*/
public class GeometryUtils {
/**
* Coordinate system of lat/lng per https://epsg.io/4326
*/
public static int GEOGRAPHY_SRID = 4326;
public static byte GEOGRAPHY_SET_MASK = (byte) 0x80;
public static byte GEOGRAPHY_GET_MASK = (byte) 0x7f;
public static final GeometryFactory GEOMETRY_FACTORY = new GeometryFactory();
public static final GeometryFactory GEOGRAPHY_FACTORY = new GeometryFactory(new PrecisionModel(), GEOGRAPHY_SRID);
public static final double EARTH_RADIUS_KM = 6371.01;
public static final double EARTH_RADIUS_M = EARTH_RADIUS_KM * 1000.0;
public static final Joiner OR_JOINER = Joiner.on(" or ");

private GeometryUtils() {
}

/**
* Checks if the given geo-spatial object is a geography object.
* @param geometry the given object to check
* @return <code>true</code> if the given geo-spatial object is a geography object, <code>false</code> otherwise
*/
public static boolean isGeography(Geometry geometry) {
return geometry.getSRID() == GEOGRAPHY_SRID;
}
}
Loading