Skip to content

Commit

Permalink
Merge branch 'multimodel-gis2' of github.com:polypheny/Polypheny-DB i…
Browse files Browse the repository at this point in the history
…nto multimodel-gis2
  • Loading branch information
datomo committed Dec 20, 2024
2 parents 3210ca7 + a36eab0 commit ab5018e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ public static PolyBoolean docGeoIntersects( PolyValue input, PolyValue geometry
@SuppressWarnings("UnusedDeclaration")
public static PolyBoolean docGeoWithin( PolyValue input, PolyValue geometry, PolyValue distance ) {
try {
// TODO: Do PolyString -> PolyGeometry conversion here
PolyGeometry geometryFilter = geometry.asGeometry();
PolyGeometry inputGeometry = convertInputToPolyGeometry( input, geometryFilter.getSRID() );
double distanceValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ public enum ExpressionType {


public PolyValue getComparable() {
if (this instanceof CypherFunctionInvocation func){
if (func.getOperatorName() == OperatorName.CYPHER_POINT){
// TODO: Call function to return PolyGeometry?
}
}
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import java.util.Map.Entry;
import java.util.stream.Collectors;
import lombok.Getter;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.PrecisionModel;
import org.polypheny.db.algebra.operators.OperatorName;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.cypher.cypher2alg.CypherToAlgConverter.CypherContext;
Expand All @@ -38,10 +42,12 @@
import org.polypheny.db.type.entity.PolyList;
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.type.entity.category.PolyNumber;
import org.polypheny.db.type.entity.graph.PolyDictionary;
import org.polypheny.db.type.entity.numerical.PolyDouble;
import org.polypheny.db.type.entity.numerical.PolyInteger;
import org.polypheny.db.type.entity.spatial.PolyGeometry;
import org.polypheny.db.type.entity.spatial.PolyPoint;
import org.polypheny.db.util.Pair;

@Getter
Expand Down Expand Up @@ -114,7 +120,15 @@ public PolyValue getComparable() {
yield new PolyList<>( list );
}
case MAP -> {
Map<PolyString, PolyValue> map = mapValue.entrySet().stream().collect( Collectors.toMap( e -> PolyString.of( e.getKey() ), e -> e.getValue().getComparable() ) );
Map<PolyString, PolyValue> map = mapValue.entrySet().stream().collect( Collectors.toMap( e -> PolyString.of( e.getKey() ), e -> {
if (e.getValue() instanceof CypherFunctionInvocation func && func.getOperatorName() == OperatorName.CYPHER_POINT ){
if (func.getArguments().get( 0 ) instanceof CypherLiteral literal){
// TODO: get real values based on key-names.
return handlePoint( new PolyDouble( 1.1 ), new PolyDouble( 1.1 ) );
}
}
return e.getValue().getComparable();
} ) );
yield new PolyDictionary( map );
}
case STRING, HEX, OCTAL -> PolyString.of( (String) value );
Expand All @@ -128,6 +142,13 @@ public PolyValue getComparable() {
};
}

public PolyGeometry handlePoint( PolyNumber latitude, PolyNumber longitude ){
GeometryFactory geometryFactory = new GeometryFactory( new PrecisionModel(), 4326 );
Coordinate coordinate = new Coordinate();
coordinate.setX( latitude.doubleValue() );
coordinate.setY( longitude.doubleValue() );
return PolyGeometry.of( geometryFactory.createPoint( coordinate ) );
}

@Override
public Pair<PolyString, RexNode> getRex( CypherContext context, RexType type ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public static void registerOperators() {

register( OperatorName.MQL_MERGE, new LangFunctionOperator( OperatorName.MQL_MERGE.name(), Kind.OTHER, PolyType.DOCUMENT ) );

register( OperatorName.MQL_MERGE_ADD, new LangFunctionOperator( OperatorName.MQL_MERGE_ADD.name(), Kind.OTHER, PolyType.DOCUMENT ) );

register( OperatorName.MQL_REPLACE_ROOT, new LangFunctionOperator( OperatorName.MQL_REPLACE_ROOT.name(), Kind.OTHER, PolyType.DOCUMENT ) );

register( OperatorName.MQL_PROJECT_INCLUDES, new LangFunctionOperator( OperatorName.MQL_PROJECT_INCLUDES.name(), Kind.OTHER, PolyType.DOCUMENT ) );
Expand Down
1 change: 1 addition & 0 deletions plugins/sql-language/src/main/codegen/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -8502,6 +8502,7 @@ void NonReservedKeyWord2of3() :
| <SUBSTITUTE>
| <TABLE_NAME>
| <TEMPORARY>
| <TEMPERATURE>
| <TIES>
| <TIMESTAMPADD>
| <TIMESTAMPDIFF>
Expand Down
3 changes: 2 additions & 1 deletion webui/src/main/java/org/polypheny/db/webui/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public static HttpServer getInstance() {
}

File uiZip = copyResourceToTempFile( uiResourceUrl, "polypheny-ui", ".zip" );


log.warn( "Unzip {} into {}", uiZip.getAbsolutePath(), uiPath.getAbsolutePath() );
PolyphenyHomeDirManager.getInstance().unzipInto( uiZip, uiPath );

Optional<File> globalUiPath = PolyphenyHomeDirManager.getInstance().getGlobalFile( "ui" );
Expand Down

0 comments on commit ab5018e

Please sign in to comment.