Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started to implement polygon/ multipolygon and functions
- Loading branch information
Showing
40 changed files
with
2,929 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/com/orientechnologies/lucene/functions/spatial/OToGeoJsonFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* * Copyright 2014 Orient Technologies. | ||
* * | ||
* * Licensed 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 com.orientechnologies.lucene.functions.spatial; | ||
|
||
import com.orientechnologies.lucene.shape.OShapeFactory; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract; | ||
|
||
/** | ||
* Created by Enrico Risa on 06/08/15. | ||
*/ | ||
public class OToGeoJsonFunction extends OSQLFunctionAbstract { | ||
|
||
public static final String NAME = "asgeojson"; | ||
|
||
OShapeFactory factory = OShapeFactory.INSTANCE; | ||
|
||
public OToGeoJsonFunction() { | ||
super(NAME, 1, 1); | ||
} | ||
|
||
@Override | ||
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, | ||
OCommandContext iContext) { | ||
return factory.asText((ODocument) iParams[0]); | ||
} | ||
|
||
@Override | ||
public String getSyntax() { | ||
return "asGeoJson(<doc>)"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/orientechnologies/lucene/functions/spatial/STContainsFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* * Copyright 2014 Orient Technologies. | ||
* * | ||
* * Licensed 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 com.orientechnologies.lucene.functions.spatial; | ||
|
||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract; | ||
|
||
/** | ||
* Created by Enrico Risa on 12/08/15. | ||
*/ | ||
public class STContainsFunction extends OSQLFunctionAbstract { | ||
|
||
public static final String NAME = "stcontains"; | ||
|
||
public STContainsFunction() { | ||
super(NAME, 2, 2); | ||
} | ||
|
||
@Override | ||
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, | ||
OCommandContext iContext) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getSyntax() { | ||
return null; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/com/orientechnologies/lucene/functions/spatial/STNearFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* | ||
* * Copyright 2014 Orient Technologies. | ||
* * | ||
* * Licensed 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 com.orientechnologies.lucene.functions.spatial; | ||
|
||
import com.orientechnologies.lucene.shape.OShapeFactory; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract; | ||
import com.spatial4j.core.distance.DistanceUtils; | ||
import com.spatial4j.core.shape.Circle; | ||
import com.spatial4j.core.shape.Point; | ||
import com.spatial4j.core.shape.Shape; | ||
import com.spatial4j.core.shape.SpatialRelation; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Created by Enrico Risa on 12/08/15. | ||
*/ | ||
public class STNearFunction extends OSQLFunctionAbstract { | ||
|
||
public static final String NAME = "st_near"; | ||
|
||
OShapeFactory factory = OShapeFactory.INSTANCE; | ||
|
||
public STNearFunction() { | ||
super(NAME, 2, 2); | ||
} | ||
|
||
@Override | ||
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, | ||
OCommandContext iContext) { | ||
Shape shape = factory.fromDoc((ODocument) iParams[0]); | ||
Map map = (Map) iParams[1]; | ||
Shape shape1 = factory.fromMapGeoJson((Map) map.get("shape")); | ||
|
||
double distance = 0; | ||
|
||
Number n = (Number) map.get("maxDistance"); | ||
if (n != null) { | ||
distance = n.doubleValue(); | ||
} | ||
Point p = (Point) shape1; | ||
Circle circle = factory.SPATIAL_CONTEXT.makeCircle(p.getX(), p.getY(), | ||
DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)); | ||
double docDistDEG = factory.SPATIAL_CONTEXT.getDistCalc().distance((Point) shape, p); | ||
final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM); | ||
iContext.setVariable("distance", docDistInKM); | ||
return shape.relate(circle) == SpatialRelation.WITHIN; | ||
} | ||
|
||
@Override | ||
public String getSyntax() { | ||
return null; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/orientechnologies/lucene/functions/spatial/STWithinFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* | ||
* * Copyright 2014 Orient Technologies. | ||
* * | ||
* * Licensed 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 com.orientechnologies.lucene.functions.spatial; | ||
|
||
import com.orientechnologies.lucene.shape.OShapeFactory; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract; | ||
import com.spatial4j.core.shape.Shape; | ||
import com.spatial4j.core.shape.SpatialRelation; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Created by Enrico Risa on 12/08/15. | ||
*/ | ||
public class STWithinFunction extends OSQLFunctionAbstract { | ||
|
||
public static final String NAME = "st_within"; | ||
|
||
OShapeFactory factory = OShapeFactory.INSTANCE; | ||
|
||
public STWithinFunction() { | ||
super(NAME, 2, 2); | ||
} | ||
|
||
@Override | ||
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, | ||
OCommandContext iContext) { | ||
|
||
Shape shape = factory.fromDoc((ODocument) iParams[0]); | ||
Map map = (Map) iParams[1]; | ||
Shape shape1 = factory.fromMapGeoJson((Map) map.get("shape")); | ||
return shape.relate(shape1) == SpatialRelation.WITHIN; | ||
} | ||
|
||
@Override | ||
public String getSyntax() { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.