Skip to content

Commit

Permalink
started geo extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Aug 6, 2015
1 parent 781bd15 commit ac25897
Show file tree
Hide file tree
Showing 25 changed files with 1,049 additions and 132 deletions.
Binary file modified plugins/studio-2.1.zip
Binary file not shown.
23 changes: 15 additions & 8 deletions pom.xml
Expand Up @@ -22,15 +22,16 @@

<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-lucene</artifactId>
<version>2.1.0</version>
<version>2.2-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<surefire.version>2.17</surefire.version>
<jdkVersion>1.6</jdkVersion>
<javac.src.version>1.6</javac.src.version>
<javac.target.version>1.6</javac.target.version>
<orientdb.version>${version}</orientdb.version>
<orientdb.version>2.1.0</orientdb.version>
<lucene.version>4.7.0</lucene.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -264,32 +265,32 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spatial</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-facet</artifactId>
<version>4.7.0</version>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
Expand All @@ -298,5 +299,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>

</dependencies>
</project>
Expand Up @@ -26,6 +26,7 @@
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseLifecycleListener;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.exception.OConfigurationException;
import com.orientechnologies.orient.core.index.OIndex;
Expand All @@ -43,7 +44,7 @@ public class OLuceneIndexFactory implements OIndexFactory, ODatabaseLifecycleLis
private static final Set<String> TYPES;
private static final Set<String> ALGORITHMS;
public static final String LUCENE_ALGORITHM = "LUCENE";

OLuceneSpatialManager spatialManager;
static {
final Set<String> types = new HashSet<String>();
types.add(OClass.INDEX_TYPE.FULLTEXT.toString());
Expand All @@ -58,6 +59,8 @@ public class OLuceneIndexFactory implements OIndexFactory, ODatabaseLifecycleLis
}

public OLuceneIndexFactory() {

spatialManager = new OLuceneSpatialManager(new OShapeFactoryImpl());
Orient.instance().addDbLifecycleListener(this);
}

Expand Down Expand Up @@ -89,7 +92,7 @@ public PRIORITY getPriority() {

@Override
public void onCreate(ODatabaseInternal iDatabase) {

spatialManager.init((ODatabaseDocumentTx) iDatabase);
}

@Override
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.orientechnologies.lucene;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.lucene.functions.spatial.OToWktFunction;
import com.orientechnologies.lucene.manager.OLuceneIndexManagerAbstract;
import com.orientechnologies.lucene.operator.OLuceneNearOperator;
import com.orientechnologies.lucene.operator.OLuceneTextOperator;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void startup() {
OSQLEngine.registerOperator(new OLuceneTextOperator());
OSQLEngine.registerOperator(new OLuceneWithinOperator());
OSQLEngine.registerOperator(new OLuceneNearOperator());
OSQLEngine.getInstance().registerFunction(OToWktFunction.NAME, new OToWktFunction());
OLogManager.instance().info(this, "Lucene index plugin installed and active. Lucene version: %s",
OLuceneIndexManagerAbstract.LUCENE_VERSION);
}
Expand All @@ -72,10 +74,12 @@ public PRIORITY getPriority() {

@Override
public void onCreate(final ODatabaseInternal iDatabase) {

}

@Override
public void onOpen(final ODatabaseInternal iDatabase) {

}

@Override
Expand Down
@@ -0,0 +1,39 @@
/*
*
* * 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;

import com.orientechnologies.lucene.shape.OShapeBuilder;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;

/**
* Created by Enrico Risa on 06/08/15.
*/
public class OLuceneSpatialManager {


private OShapeBuilder shapeFactory;

public OLuceneSpatialManager(OShapeBuilder oShapeBuilder) {
shapeFactory = oShapeBuilder;
}

public void init(ODatabaseDocumentTx db) {
shapeFactory.initClazz(db);
}
}
@@ -0,0 +1,25 @@
/*
*
* * 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.exception;

/**
* Created by Enrico Risa on 06/08/15.
*/
public class OSpatialException extends Exception {
}
Expand Up @@ -15,22 +15,21 @@
*/
package com.orientechnologies.lucene.functions;

import com.orientechnologies.lucene.functions.spatial.OToWktFunction;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.sql.functions.OSQLFunction;
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionFactory;
import com.orientechnologies.orient.core.sql.functions.math.OSQLFunctionAverage;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;


public class OLuceneFunctionsFactory implements OSQLFunctionFactory {

private static final Map<String, Object> FUNCTIONS = new HashMap<String, Object>();

static {
register(OLuceneNearFunction.NAME, OLuceneNearFunction.class);
register(OToWktFunction.NAME, OToWktFunction.class);
}

@Override
Expand Down

This file was deleted.

@@ -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.OShapeFactoryImpl;
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 OToWktFunction extends OSQLFunctionAbstract {

public static final String NAME = "towkt";

OShapeFactoryImpl factory = new OShapeFactoryImpl();

public OToWktFunction() {
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 "toWKT(<doc>)";
}
}

0 comments on commit ac25897

Please sign in to comment.