Hi,
I am using Geomesa as a database of various sensor measurements. Each sensor's geometry type may vary from Point and LineString to Polygon. Is it possible to store all of them as a feature type and query in a single way?
I currently implement each geometry type as different attributes and define default geometry per feature.
The simplified version of my implementation is:
### Adding an entry
```java
// Define Feature Type
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("TestFeatureType");
b.add("point_loc", Point.class, 4326);
b.add("line_loc", LineString.class, 4326)
b.add("date", Date.class);
b.add("value", String.class);
b.setDefaultGeometry("point_loc");
SimpleFeatureType featType = b.buildFeatureType();
dataStore.createSchema(featType); // Assume dataStore is loaded.
// Write a feature
FeatureWriter writer = dataStore.getFeatureWriterAppend("TestFeatureType");
// Adding a sensor value with geometry type "LineString"
SimpleFeature newFeature = writer.next();
newFeature.setAttribute("value", "TestValue1");
newFeature.setAttribute("date", SomeDate);
newFeature.setAttribute("line_loc", line); // line is given.
// Not adding point ad line is included.
```
### Querying the value.
```
String cqlGeometry = "BBOX( line_loc, x1, y1, x2, y2)" // Given BBOX includes the point added above.
Filter filter = CQL.toFilter(cqlGeometry);
Query q = new Query("TestFeatureType", filter);
q.getHints().put(QueryHints.LOOSE_BBOX(), Boolean.FALSE);
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource("TestFeatureType");
FeatureIterator<SimpleFeature> featureItr = featureSource.getFeatures(query).features();
// This iterator turns out to be empty.
while (featureItr.hasNext()) {
Feature feat = featureItr.next();
System.out.println(feat);
}
```
My questions are
1. Is it okay to define multiple geometry types into a single feature type?
2. Can default geometry type be changed per every feature?
3. How can I properly get query results for the above case?
4. Is there anyway that I can query both point_loc and line_loc with a single query? Should I just need to OR two geometry filters? (Is there a better way?)
Thank you so much and I hope that one day I can share the entire project as an instance of using Geomesa.