Author: apm Date: 2011-12-08 06:22:32 -0800 (Thu, 08 Dec 2011) New Revision: 38411 Added: trunk/modules/unsupported/mongodb/ trunk/modules/unsupported/mongodb/README.rst trunk/modules/unsupported/mongodb/pom.xml trunk/modules/unsupported/mongodb/src/ trunk/modules/unsupported/mongodb/src/main/ trunk/modules/unsupported/mongodb/src/main/java/ trunk/modules/unsupported/mongodb/src/main/java/org/ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/FilterToMongoQuery.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureCollection.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureReader.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureSource.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoLayer.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoPluginConfig.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoPluginException.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoQueryCaps.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoResourceInfo.java trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoResultSet.java trunk/modules/unsupported/mongodb/src/main/javascript/ trunk/modules/unsupported/mongodb/src/main/javascript/INSTALL.txt trunk/modules/unsupported/mongodb/src/main/javascript/MetaDataCompute.js trunk/modules/unsupported/mongodb/src/main/resources/ trunk/modules/unsupported/mongodb/src/main/resources/META-INF/ trunk/modules/unsupported/mongodb/src/main/resources/META-INF/services/ trunk/modules/unsupported/mongodb/src/main/resources/META-INF/services/org.geotools.data.DataStoreFactorySpi trunk/modules/unsupported/mongodb/src/site/ trunk/modules/unsupported/mongodb/src/site/apt/ trunk/modules/unsupported/mongodb/src/site/apt/review.apt trunk/modules/unsupported/mongodb/target/ Modified: trunk/modules/unsupported/pom.xml Log: Added MongoDB data store to modules/unsupported Added: trunk/modules/unsupported/mongodb/README.rst =================================================================== --- trunk/modules/unsupported/mongodb/README.rst (rev 0) +++ trunk/modules/unsupported/mongodb/README.rst 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,18 @@ +MongoDB DataStore +================= + +Installing MongoDB +------------------------- + +Install MongoDB using the appropriate package from: +http://www.mongodb.org/downloads + +The MongoDB plugin depends on a JavaScript MapReduce script to calculate schema. The script (MetaDataCompute.js), and installation specifics (INSTALL.txt), can be found in modules/unsupported/mongodb/src/main/javascript/. Install this script on your MongoDB server. + +Functionality +------------- + +The MongoDataStore supports the use of MongoDB as a data store. This should be considered a beta version. + +The current 'design document' in use for the test cases is not necessarily the +final solution and is acknowledged to have shortcomings. Property changes on: trunk/modules/unsupported/mongodb/README.rst ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/pom.xml =================================================================== --- trunk/modules/unsupported/mongodb/pom.xml (rev 0) +++ trunk/modules/unsupported/mongodb/pom.xml 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.geotools</groupId> + <artifactId>unsupported</artifactId> + <version>8-SNAPSHOT</version> + </parent> + + <groupId>org.geotools</groupId> + <artifactId>gt-mongodb</artifactId> + <packaging>jar</packaging> + <name>MongoDB DataStore</name> + <description>MongoDB DataStore.</description> + + <developers> + <developer> + <id>apm</id> + <name>Alan Mangan</name> + <email>am...@da...</email> + <organization>Data Tactics Corp.</organization> + <organizationUrl>http://www.data-tactics-corp.com</organizationUrl> + <timezone>GMT-5</timezone> + <roles> + <role>Java Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <!-- GeoTools modules --> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-main</artifactId> + <version>${project.version}</version> + </dependency> + <!-- Third-party dependencies --> + <dependency> + <groupId>org.mongodb</groupId> + <artifactId>mongo-java-driver</artifactId> + <version>2.5</version> + <type>jar</type> + <optional>false</optional> + </dependency> + + </dependencies> + +</project> Property changes on: trunk/modules/unsupported/mongodb/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/FilterToMongoQuery.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/FilterToMongoQuery.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/FilterToMongoQuery.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,685 @@ +package org.geotools.data.mongodb; + +import java.util.Iterator; +import java.util.List; +import java.util.regex.Pattern; + +import org.opengis.filter.And; +import org.opengis.filter.ExcludeFilter; +import org.opengis.filter.Filter; +import org.opengis.filter.FilterVisitor; +import org.opengis.filter.Id; +import org.opengis.filter.IncludeFilter; +import org.opengis.filter.Not; +import org.opengis.filter.Or; +import org.opengis.filter.PropertyIsBetween; +import org.opengis.filter.PropertyIsEqualTo; +import org.opengis.filter.PropertyIsGreaterThan; +import org.opengis.filter.PropertyIsGreaterThanOrEqualTo; +import org.opengis.filter.PropertyIsLessThan; +import org.opengis.filter.PropertyIsLessThanOrEqualTo; +import org.opengis.filter.PropertyIsLike; +import org.opengis.filter.PropertyIsNil; +import org.opengis.filter.PropertyIsNotEqualTo; +import org.opengis.filter.PropertyIsNull; +import org.opengis.filter.expression.Add; +import org.opengis.filter.expression.Divide; +import org.opengis.filter.expression.Expression; +import org.opengis.filter.expression.ExpressionVisitor; +import org.opengis.filter.expression.Function; +import org.opengis.filter.expression.Literal; +import org.opengis.filter.expression.Multiply; +import org.opengis.filter.expression.NilExpression; +import org.opengis.filter.expression.PropertyName; +import org.opengis.filter.expression.Subtract; +import org.opengis.filter.spatial.BBOX; +import org.opengis.filter.spatial.Beyond; +import org.opengis.filter.spatial.Contains; +import org.opengis.filter.spatial.Crosses; +import org.opengis.filter.spatial.DWithin; +import org.opengis.filter.spatial.Disjoint; +import org.opengis.filter.spatial.Equals; +import org.opengis.filter.spatial.Intersects; +import org.opengis.filter.spatial.Overlaps; +import org.opengis.filter.spatial.Touches; +import org.opengis.filter.spatial.Within; +import org.opengis.filter.temporal.After; +import org.opengis.filter.temporal.AnyInteracts; +import org.opengis.filter.temporal.Before; +import org.opengis.filter.temporal.Begins; +import org.opengis.filter.temporal.BegunBy; +import org.opengis.filter.temporal.During; +import org.opengis.filter.temporal.EndedBy; +import org.opengis.filter.temporal.Ends; +import org.opengis.filter.temporal.Meets; +import org.opengis.filter.temporal.MetBy; +import org.opengis.filter.temporal.OverlappedBy; +import org.opengis.filter.temporal.TContains; +import org.opengis.filter.temporal.TEquals; +import org.opengis.filter.temporal.TOverlaps; + +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Geometry; + +/** + * + * @author Gerald Gay, Data Tactics Corp. + * @author Alan Mangan, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class FilterToMongoQuery implements FilterVisitor, ExpressionVisitor +{ + + // temp holder + public FilterToMongoQuery () + { + } + + protected BasicDBObject asDBObject (Object extraData) + { + if ((extraData != null) || (extraData instanceof BasicDBObject)) + { + return (BasicDBObject) extraData; + } + return new BasicDBObject(); + } + + public Object visit (Literal expression, Object extraData) + { + Object literal = expression.getValue(); + String ret = literal.toString(); + return ret; + } + + public Object visit (PropertyName expression, Object extraData) + { + return expression.getPropertyName(); + } + + public Object visit (ExcludeFilter filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + output.put( "foo", "not_likely_to_exist" ); + return output; + } + + // An empty object should be an "all" query + public Object visit (IncludeFilter filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + return output; + } + + // Expressions like ((A == 1) AND (B == 2)) are basically + // implied. So just build up all sub expressions + public Object visit (And filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + + List<Filter> children = filter.getChildren(); + if (children != null) + { + for (Iterator<Filter> i = children.iterator(); i.hasNext();) + { + Filter child = i.next(); + child.accept( this, output ); + } + } + + return output; + } + + /** + * Encoding an Id filter is not supported by CQL. + * <p> + * This is because in the Catalog specification retrieving an object by an id is a distinct + * operation separate from a filter based query. + */ + public Object visit (Id filter, Object extraData) + { + throw new IllegalStateException( "Cannot encode an Id as legal CQL" ); + } + + public Object visit (Not filter, Object extraData) + { + + BasicDBObject output = asDBObject( extraData ); + BasicDBObject expr = (BasicDBObject) filter.getFilter().accept( this, null ); + output.put( "$not", expr ); + return output; + } + + public Object visit (Or filter, Object extraData) + { + + BasicDBObject output = asDBObject( extraData ); + List<Filter> children = filter.getChildren(); + BasicDBList orList = new BasicDBList(); + if (children != null) + { + for (Iterator<Filter> i = children.iterator(); i.hasNext();) + { + Filter child = i.next(); + BasicDBObject item = (BasicDBObject) child.accept( this, null ); + orList.add( item ); + } + output.put( "$or", orList ); + } + return output; + } + + public Object visit (PropertyIsBetween filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object propName = filter.getExpression().accept( this, null ); + Object lower = filter.getLowerBoundary().accept( this, null ); + Object upper = filter.getUpperBoundary().accept( this, null ); + if ((propName instanceof String) && (lower instanceof String) && (upper instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + dbo.put( "$gte", lower ); + dbo.put( "$lte", upper ); + output.put( (String) propName, dbo ); + } + return output; + } + + public Object visit (PropertyIsEqualTo filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + // try to determine if equality check against a number, and if so whether fp or int + // assuming no units/currency markings present, e.g. "$" "ft." etc. + String expr2Str = ((String) expr2).trim(); + try + { + if (expr2Str.matches( "-? ?(\\d+,)*\\d+" )) // integer + { + output.put( (String) expr1, new Long( (String) expr2 ) ); + } + else if (expr2Str.matches( "-? ?(\\d+,)*\\d+\\.\\d+" )) // floating point + { + output.put( (String) expr1, new Double( (String) expr2 ) ); + } + else + { + output.put( (String) expr1, expr2 ); + } + } + catch (NumberFormatException e) + { + output.put( (String) expr1, expr2 ); + } + } + return output; + } + + public Object visit (PropertyIsNotEqualTo filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + try + { + dbo.put( "$ne", new Double( (String) expr2 ) ); + } + catch (NumberFormatException e) + { + dbo.put( "$ne", expr2 ); + } + output.put( (String) expr1, dbo ); + } + return output; + } + + public Object visit (PropertyIsGreaterThan filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + try + { + dbo.put( "$gt", new Double( (String) expr2 ) ); + } + catch (NumberFormatException e) + { + dbo.put( "$gt", expr2 ); + } + output.put( (String) expr1, dbo ); + } + return output; + } + + public Object visit (PropertyIsGreaterThanOrEqualTo filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + try + { + dbo.put( "$gte", new Double( (String) expr2 ) ); + } + catch (NumberFormatException e) + { + dbo.put( "$gte", expr2 ); + } + output.put( (String) expr1, dbo ); + } + return output; + } + + public Object visit (PropertyIsLessThan filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + try + { + dbo.put( "$lt", new Double( (String) expr2 ) ); + } + catch (NumberFormatException e) + { + dbo.put( "$lt", expr2 ); + } + output.put( (String) expr1, dbo ); + } + return output; + } + + public Object visit (PropertyIsLessThanOrEqualTo filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr1 = filter.getExpression1().accept( this, null ); + Object expr2 = filter.getExpression2().accept( this, null ); + if ((expr1 instanceof String) && (expr2 instanceof String)) + { + BasicDBObject dbo = new BasicDBObject(); + try + { + dbo.put( "$lte", new Double( (String) expr2 ) ); + } + catch (NumberFormatException e) + { + dbo.put( "$lte", expr2 ); + } + output.put( (String) expr1, dbo ); + } + return output; + } + + // Mongo doesn't have LIKE but it does have Regex. So + // I'm converting it like this: + // + // filter.getWildCard() returns SQL-like '%' + // filter.getSingleChar() returns SQL-like '_' + // So I'm converting "foo_bar%" to /foo.bar.*/ + public Object visit (PropertyIsLike filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr = filter.getExpression(); + if (expr instanceof String) + { + String multi = filter.getWildCard(); + String single = filter.getSingleChar(); + int flags = (filter.isMatchingCase()) ? 0 : Pattern.CASE_INSENSITIVE; + String cqlPattern = filter.getLiteral(); + cqlPattern.replaceAll( multi, ".*" ); + cqlPattern.replaceAll( single, "." ); + try + { + Pattern p = Pattern.compile( cqlPattern, flags ); + output.put( (String) expr, p ); + } + catch (Throwable t) + { + } + } + return output; + } + + // There is no "NULL" in MongoDB, but I assume that TODO add null support + // the non-existence of a column is the same... + public Object visit (PropertyIsNull filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + Object expr = filter.accept( this, null ); + if (expr instanceof String) + { + BasicDBObject dbo = new BasicDBObject(); + dbo.put( "$exists", false ); + output.put( (String) expr, dbo ); + } + return output; + } + + public Object visit (BBOX filter, Object extraData) + { + BasicDBObject output = asDBObject( extraData ); + + double minX = 180; + double minY = 90; + double maxX = -180; + double maxY = -90; + // replace deprecated BBOX.getMinX() w/ getExpression2() call + // to determine mins and maxes + Expression exp2 = filter.getExpression2(); + if (exp2 instanceof Literal) + { + Geometry bbox = (Geometry) ((Literal) exp2).getValue(); + Coordinate[] coords = bbox.getEnvelope().getCoordinates(); + minX = coords[0].x; + minY = coords[0].y; + maxX = coords[2].x; + maxY = coords[2].y; + } + + if (minX < -180) + minX = -180; + if (maxX > 180) + maxX = 180; + if (minY < -90) + minY = -90; + if (maxY > 90) + maxY = 90; + + StringBuilder sb = new StringBuilder(); + sb.append( "gtmpGeoQuery([" ); + sb.append( minX ); + sb.append( "," ); + sb.append( minY ); + sb.append( "," ); + sb.append( maxX ); + sb.append( "," ); + sb.append( maxY ); + sb.append( "])" ); + output.put( "$where", sb.toString() ); + + return output; + } + + public Object visitNullFilter (Object extraData) + { + throw new NullPointerException( "Cannot encode null as a Filter" ); + } + + public Object visit (NilExpression expression, Object extraData) + { + return extraData; + } + + /****************************************************** + * The rest are either filters that don't make sense or are currently not implemented. + ******************************************************/ + + public Object visit (Beyond filter, Object extraData) + { + return extraData; + } + + public Object visit (Contains filter, Object extraData) + { + return extraData; + } + + public Object visit (Crosses filter, Object extraData) + { + return extraData; + } + + public Object visit (Disjoint filter, Object extraData) + { + return extraData; + } + + public Object visit (DWithin filter, Object extraData) + { + return extraData; + } + + public Object visit (Equals filter, Object extraData) + { + return extraData; + } + + public Object visit (Intersects filter, Object extraData) + { + return extraData; + } + + public Object visit (Overlaps filter, Object extraData) + { + return extraData; + } + + public Object visit (Touches filter, Object extraData) + { + return extraData; + } + + public Object visit (Within filter, Object extraData) + { + return extraData; + } + + public Object visit (Add expression, Object extraData) + { + return extraData; + } + + public Object visit (Divide expression, Object extraData) + { + return extraData; + } + + public Object visit (Function function, Object extraData) + { + return extraData; + } + + public Object visit (Multiply expression, Object extraData) + { + return extraData; + } + + public Object visit (Subtract expression, Object extraData) + { + return extraData; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.PropertyIsNil, + * java.lang.Object) */ + @Override + public Object visit (PropertyIsNil filter, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.After, + * java.lang.Object) */ + @Override + public Object visit (After after, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.AnyInteracts, + * java.lang.Object) */ + @Override + public Object visit (AnyInteracts anyInteracts, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.Before, + * java.lang.Object) */ + @Override + public Object visit (Before before, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.Begins, + * java.lang.Object) */ + @Override + public Object visit (Begins begins, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.BegunBy, + * java.lang.Object) */ + @Override + public Object visit (BegunBy begunBy, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.During, + * java.lang.Object) */ + @Override + public Object visit (During during, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.EndedBy, + * java.lang.Object) */ + @Override + public Object visit (EndedBy endedBy, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.Ends, + * java.lang.Object) */ + @Override + public Object visit (Ends ends, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.Meets, + * java.lang.Object) */ + @Override + public Object visit (Meets meets, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.MetBy, + * java.lang.Object) */ + @Override + public Object visit (MetBy metBy, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.OverlappedBy, + * java.lang.Object) */ + @Override + public Object visit (OverlappedBy overlappedBy, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.TContains, + * java.lang.Object) */ + @Override + public Object visit (TContains contains, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.TEquals, + * java.lang.Object) */ + @Override + public Object visit (TEquals equals, Object extraData) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * + * @see org.opengis.filter.FilterVisitor#visit(org.opengis.filter.temporal.TOverlaps, + * java.lang.Object) */ + @Override + public Object visit (TOverlaps contains, Object extraData) + { + // TODO Auto-generated method stub + return null; + } +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/FilterToMongoQuery.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,350 @@ +package org.geotools.data.mongodb; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.logging.Logger; + +import org.bson.types.BasicBSONList; +import org.geotools.data.DataStore; +import org.geotools.data.DefaultServiceInfo; +import org.geotools.data.EmptyFeatureWriter; +import org.geotools.data.FeatureListener; +import org.geotools.data.FeatureListenerManager; +import org.geotools.data.FeatureReader; +import org.geotools.data.FeatureSource; +import org.geotools.data.FeatureWriter; +import org.geotools.data.LockingManager; +import org.geotools.data.Query; +import org.geotools.data.ServiceInfo; +import org.geotools.data.Transaction; +import org.geotools.data.mongodb.MongoLayer.GeometryType; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.feature.NameImpl; +import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.referencing.CRS; +import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; +import org.opengis.filter.Filter; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.Mongo; +import com.mongodb.MongoException; + +/** + * Represents a mongoDB-backed GeoServer Data Store; manages layers representing mongoDB collections + * containing GeoJSON-encoded geospatial data + * + * @author Gerald Gay, Data Tactics Corp. + * @author Alan Mangan, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoDataStore implements DataStore +{ + + /** List of mongo layers for this mongo store */ + private ArrayList<MongoLayer> layers = null; + private CoordinateReferenceSystem crs = null; + /** Config for this mongo plugin */ + private MongoPluginConfig config = null; + private FeatureListenerManager lsnMgr = null; + + /** Package logger */ + private final static Logger log = MongoPluginConfig.getLog(); + + public MongoDataStore (MongoPluginConfig config) + { + this.config = config; + lsnMgr = new FeatureListenerManager(); + layers = new ArrayList<MongoLayer>(); + log.info( "MongoDataStore; layers=" + layers ); + try + { + crs = CRS.decode( "EPSG:4326" ); + } + catch (Throwable t) + { + crs = DefaultGeographicCRS.WGS84; + } + // TODO when to look for and detect changes to layers + if (layers.size() == 0) + { + getLayers(); + } + } + + /** + * Get list of valid layers for this mongo DB; those containing at least one valid, non-null + * GeoJSON geometry + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void getLayers () + { + Mongo mongo = null; + try + { + // Get the list of collections from Mongo... + mongo = new Mongo( config.getHost(), config.getPort() ); + DB db = mongo.getDB( config.getDB() ); // TODO add authentication + Set<String> colls = db.getCollectionNames(); + for (String s : colls) + { + DBCollection dbc = db.getCollection( s ); + log.info( "getLayers; collection=" + dbc ); + // find distinct non-null geometry to determine if valid layer + // TODO branch point for separate geometry-specific layers per collection + List geoList = dbc.distinct( "geometry.type" ); + // distinct returns single BSON List, may barf if results large, > max doc. size + // trap exception on props distinct and assume it's valid since there's obviously + // something there (http://www.mongodb.org/display/DOCS/Aggregation) + List propList = null; + try + { + propList = dbc.distinct( "properties" ); + } + catch (IllegalArgumentException ex) + { + propList = new BasicBSONList(); + propList.add( "ex nihilo" ); + } + catch (MongoException ex) + { + propList = new BasicBSONList(); + propList.add( "ex nihilo" ); + } + // check that layer has valid geometry and some properties defined + if (geoList != null && propList != null && propList.size() > 0) + { + boolean hasValidGeo = false; + for (GeometryType type : GeometryType.values()) + { + if (geoList.contains( type.toString() )) + { + hasValidGeo = true; + break; + } + } + if (hasValidGeo) + { + layers.add( new MongoLayer( dbc, config ) ); + } + } + } + } + catch (Throwable t) + { + log.severe( "getLayers error; " + t.getLocalizedMessage() ); + } + if (mongo != null) + { + mongo.close(); + } + } + + public CoordinateReferenceSystem getCRS () + { + return crs; + } + + public MongoPluginConfig getConfig () + { + return config; + } + + public void addListener (FeatureSource<?, ?> src, FeatureListener listener) + { + lsnMgr.addFeatureListener( src, listener ); + } + + public void removeListener (FeatureSource<?, ?> src, FeatureListener listener) + { + lsnMgr.removeFeatureListener( src, listener ); + } + + public Set<String> getKeywords (String typeName) + { + Set<String> result = null; + + for (MongoLayer ml : layers) + { + if (ml.getName().equals( typeName )) + { + result = ml.getKeywords(); + break; + } + } + + return result; + } + + public LockingManager getLockingManager () + { + // returning null as per DataStore.getLockingManager() contract + return null; + } + + public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend (final String typeName, + final Transaction transaction) + { + return new EmptyFeatureWriter( new SimpleFeatureTypeBuilder().buildFeatureType() ); + } + + public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter (final String typeName, + final Transaction transaction) + { + return new EmptyFeatureWriter( new SimpleFeatureTypeBuilder().buildFeatureType() ); + } + + public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter (final String typeName, + final Filter filter, + final Transaction transaction) + { + return new EmptyFeatureWriter( new SimpleFeatureTypeBuilder().buildFeatureType() ); + } + + public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader (final Query query, + final Transaction transaction) + { + FilterToMongoQuery f2m = new FilterToMongoQuery(); + Filter filter = query.getFilter(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoLayer layer = getMongoLayer( query.getTypeName() ); + MongoResultSet rs = new MongoResultSet( layer, dbo ); + return new MongoFeatureReader( rs ); + } + + public SimpleFeatureSource getFeatureSource (final String typeName) throws IOException + { + MongoLayer layer = getMongoLayer( typeName ); + return new MongoFeatureSource( this, layer ); + } + + public FeatureSource<SimpleFeatureType, SimpleFeature> getView (final Query query) + { + FilterToMongoQuery f2m = new FilterToMongoQuery(); + Filter filter = query.getFilter(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoLayer layer = getMongoLayer( query.getTypeName() ); + return new MongoFeatureSource( this, layer, dbo ); + } + + public SimpleFeatureType getSchema (final String typeName) + { + SimpleFeatureType sft = null; + + for (MongoLayer ml : layers) + { + if (ml.getName().equals( typeName )) + { + sft = ml.getSchema(); + } + } + + return sft; + } + + public String[] getTypeNames () + { + String[] names = new String[layers.size()]; + int idx = 0; + for (MongoLayer ml : layers) + { + names[idx++] = ml.getName(); + } + return names; + } + + public void updateSchema (final String typeName, final SimpleFeatureType featureType) + throws IOException + { + throw new UnsupportedOperationException( "Schema modification not supported" ); + } + + public void dispose () + { + + } + + public SimpleFeatureSource getFeatureSource (Name name) throws IOException + { + return getFeatureSource( name.getLocalPart() ); + } + + public SimpleFeatureType getSchema (Name name) throws IOException + { + return getSchema( name.getLocalPart() ); + } + + public List<Name> getNames () throws IOException + { + List<Name> names = new ArrayList<Name>( layers.size() ); + for (MongoLayer ml : layers) + { + names.add( new NameImpl( ml.getName() ) ); + } + return names; + } + + public void updateSchema (Name typeName, SimpleFeatureType featureType) throws IOException + { + updateSchema( typeName.getLocalPart(), featureType ); + } + + public void createSchema (final SimpleFeatureType featureType) throws IOException, + IllegalArgumentException + { + + } + + public ServiceInfo getInfo () + { + DefaultServiceInfo info = new DefaultServiceInfo(); + info.setTitle( "MongoDB Data Store" ); + info.setDescription( "Features from MongoDB" ); + try + { + info.setSchema( new URI( config.getNamespace() ) ); + } + catch (Throwable t) + { + } + return info; + } + + public MongoLayer getMongoLayer (String typeName) + { + MongoLayer layer = null; + for (MongoLayer ml : layers) + { + if (ml.getName().equals( typeName )) + { + layer = ml; + break; + } + } + return layer; + } + +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,116 @@ +package org.geotools.data.mongodb; + +import java.awt.RenderingHints; +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import org.geotools.data.DataStore; +import org.geotools.data.DataStoreFactorySpi; + +/** + * + * @author Gerald Gay, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoDataStoreFactory implements DataStoreFactorySpi +{ + + private static final String FACTORY_DESCRIPTION = "MongoDB GeoServer Plugin"; + private static final String FACTORY_DISPLAY_NAME = "MongoDB"; + /** Package logger */ + static private final Logger log = MongoPluginConfig.getLog(); + + public DataStore createNewDataStore (Map<String, Serializable> map) + { + return createDataStore( map ); + } + + public DataStore createDataStore (Map<String, Serializable> params) + { + DataStore theStore = null; + log.info( "DataStore.createDataStore()" ); + try + { + MongoPluginConfig config = new MongoPluginConfig( params ); + theStore = new MongoDataStore( config ); + log.info( "DataStore.createDataStore(); theStore=" + theStore ); + } + catch (Throwable t) + { + log.severe( t.getLocalizedMessage() ); + } + return theStore; + } + + public boolean isAvailable () + { + boolean result = false; + try + { + // basic check to ensure mongo jar available + Class.forName( "com.mongodb.BasicDBObject" ); + result = true; + } + catch (Throwable t) + { + log.severe( "Mongo Plugin: The MongoDB JAR file was not found on the class path." ); + } + return result; + } + + public boolean canProcess (Map<String, Serializable> params) + { + + boolean result = true; + + try + { + new MongoPluginConfig( params ); + } + catch (MongoPluginException e) + { + result = false; + } + + return result; + } + + public DataStoreFactorySpi.Param[] getParametersInfo () + { + List<Param> params = MongoPluginConfig.getPluginParams(); + return params.toArray( new Param[params.size()] ); + } + + public String getDescription () + { + return FACTORY_DESCRIPTION; + } + + public String getDisplayName () + { + return FACTORY_DISPLAY_NAME; + } + + public Map<RenderingHints.Key, ?> getImplementationHints () + { + return Collections.emptyMap(); + } +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureCollection.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureCollection.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureCollection.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,62 @@ +package org.geotools.data.mongodb; + +import org.geotools.data.FeatureReader; +import org.geotools.data.store.DataFeatureCollection; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; + +/** + * + * @author Gerald Gay, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoFeatureCollection extends DataFeatureCollection +{ + + private MongoResultSet results = null; + + public MongoFeatureCollection (MongoResultSet rs) + { + results = rs; + } + + @Override + public int getCount () + { + return results.getCount(); + } + + @Override + public ReferencedEnvelope getBounds () + { + return results.getBounds(); + } + + @Override + public SimpleFeatureType getSchema () + { + return results.getSchema(); + } + + @Override + public FeatureReader<SimpleFeatureType, SimpleFeature> reader () + { + return new MongoFeatureReader( results ); + } +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureCollection.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureReader.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureReader.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureReader.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,57 @@ +package org.geotools.data.mongodb; + +import org.geotools.data.FeatureReader; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; + +/** + * + * @author Gerald Gay, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoFeatureReader implements FeatureReader<SimpleFeatureType, SimpleFeature> +{ + + private MongoResultSet results; + private int next = 0; + + public MongoFeatureReader (MongoResultSet rs) + { + results = rs; + } + + public void close () + { + } + + public boolean hasNext () + { + return (next < results.getCount()); + } + + public SimpleFeature next () + { + return results.getFeature( next++ ); + } + + public SimpleFeatureType getFeatureType () + { + return results.getSchema(); + } + +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureReader.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureSource.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureSource.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureSource.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,181 @@ +package org.geotools.data.mongodb; + +import java.awt.RenderingHints; +import java.util.Collections; +import java.util.Set; + +import org.geotools.data.DataStore; +import org.geotools.data.FeatureListener; +import org.geotools.data.Query; +import org.geotools.data.QueryCapabilities; +import org.geotools.data.ResourceInfo; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; +import org.opengis.filter.Filter; + +import com.mongodb.BasicDBObject; + +/** + * + * @author Gerald Gay, Data Tactics Corp. + * @author Alan Mangan, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoFeatureSource implements SimpleFeatureSource +{ + + private MongoDataStore store; + private MongoLayer layer = null; + private MongoResultSet results = null; + private MongoQueryCaps queryCaps = new MongoQueryCaps(); + private MongoResourceInfo info = null; + + public MongoFeatureSource (MongoDataStore store, MongoLayer layer) + { + init( store, layer, null ); + } + + public MongoFeatureSource (MongoDataStore store, MongoLayer layer, BasicDBObject dbo) + { + init( store, layer, dbo ); + } + + private void init (MongoDataStore store, MongoLayer layer, BasicDBObject dbo) + { + this.store = store; + this.layer = layer; + BasicDBObject query = dbo; + if (query == null) + { + query = new BasicDBObject(); + } + results = new MongoResultSet( layer, query ); + info = new MongoResourceInfo( this ); + } + + public MongoLayer getLayer () + { + return layer; + } + + public ReferencedEnvelope getBounds () + { + return results.getBounds(); + } + + public Set<String> getKeywords () + { + return layer.getKeywords(); + } + + public final Set<RenderingHints.Key> getSupportedHints () + { + return Collections.emptySet(); + } + + public final int getCount (final Query query) + { + int res = 0; + FilterToMongoQuery f2m = new FilterToMongoQuery(); + Filter filter = query.getFilter(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoResultSet rs = new MongoResultSet( layer, dbo ); + res = rs.getCount(); + return res; + } + + public final ReferencedEnvelope getBounds (final Query query) + { + FilterToMongoQuery f2m = new FilterToMongoQuery(); + Filter filter = query.getFilter(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoResultSet rs = new MongoResultSet( layer, dbo ); + return rs.getBounds(); + } + + public final SimpleFeatureCollection getFeatures () + { + return new MongoFeatureCollection( results ); + } + + public final SimpleFeatureCollection getFeatures (final Filter filter) + { + FilterToMongoQuery f2m = new FilterToMongoQuery(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoResultSet rs = new MongoResultSet( layer, dbo ); + return new MongoFeatureCollection( rs ); + } + + public final SimpleFeatureCollection getFeatures (final Query query) + { + FilterToMongoQuery f2m = new FilterToMongoQuery(); + Filter filter = query.getFilter(); + BasicDBObject dbo = (BasicDBObject) filter.accept( f2m, null ); + MongoResultSet rs = new MongoResultSet( layer, dbo ); + // check for paging; maxFeatures and/or startIndex + int maxFeatures = query.getMaxFeatures(); + if (maxFeatures > 0) + { + int startIndex = 0; + if (query.getStartIndex() != null) + { + startIndex = query.getStartIndex().intValue(); + } + rs.paginateFeatures( startIndex, maxFeatures ); + } + return new MongoFeatureCollection( rs ); + } + + public final SimpleFeatureType getSchema () + { + return layer.getSchema(); + } + + public final void addFeatureListener (final FeatureListener listener) + { + store.addListener( this, listener ); + } + + public final void removeFeatureListener (final FeatureListener listener) + { + store.removeListener( this, listener ); + } + + public final DataStore getDataStore () + { + return store; + } + + public QueryCapabilities getQueryCapabilities () + { + return queryCaps; + } + + public ResourceInfo getInfo () + { + return info; + } + + public Name getName () + { + return layer.getSchema().getName(); + } +} Property changes on: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoFeatureSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Id URL Added: svn:eol-style + native Added: trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoLayer.java =================================================================== --- trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoLayer.java (rev 0) +++ trunk/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoLayer.java 2011-12-08 14:22:32 UTC (rev 38411) @@ -0,0 +1,601 @@ +package org.geotools.data.mongodb; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Logger; + +import org.bson.BSONObject; +import org.bson.BasicBSONObject; +import org.bson.types.BasicBSONList; +import org.geotools.feature.AttributeTypeBuilder; +import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.referencing.CRS; +import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import com.mongodb.Bytes; +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; +import com.vividsolutions.jts.geom.GeometryCollection; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.MultiLineString; +import com.vividsolutions.jts.geom.MultiPoint; +import com.vividsolutions.jts.geom.MultiPolygon; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; + +/** + * Represents a GeoServer layer consisting of valid GeoJSON-encoded data from a mongoDB collection. + * (A single collection containing different geometry types (Point, Polygon etc.) may be represented + * by multiple layers.) + * + * @author Gerald Gay, Data Tactics Corp. + * @author Alan Mangan, Data Tactics Corp. + * @source $URL$ + * + * (C) 2011, Open Source Geospatial Foundation (OSGeo) + * + * @see The GNU Lesser General Public License (LGPL) + */ +/* This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ +public class MongoLayer +{ + + private MongoPluginConfig config = null; + private String ... [truncated message content] |