@Override protected ExplicitSpatialQuery newConstraints() { return new ExplicitSpatialQuery(); }
@Override public List<MultiDimensionalNumericData> getIndexConstraints(final Index index) { final String indexCrsStr = getCrs(index.getIndexModel()); CrsCache cache = crsCodeCache.get(indexCrsStr); if (cache != null) { List<MultiDimensionalNumericData> indexConstraints = cache.constraintsPerIndexId.get(index.getName()); if (indexConstraints == null) { if (crsMatches(crsCode, indexCrsStr) || (queryGeometry == null)) { indexConstraints = super.getIndexConstraints(index); } else { indexConstraints = indexConstraintsFromGeometry(cache.geometry, index); } cache.constraintsPerIndexId.put(index.getName(), indexConstraints); } return indexConstraints; } cache = transformToIndex(indexCrsStr, index); crsCodeCache.put(indexCrsStr, cache); return cache.constraintsPerIndexId.get(index.getName()); }
@Override protected QueryFilter createQueryFilter( final MultiDimensionalNumericData constraints, final NumericDimensionField<?>[] orderedConstrainedDimensionFields, final NumericDimensionField<?>[] unconstrainedDimensionDefinitions, final Index index) { return new SpatialQueryFilter( constraints, orderedConstrainedDimensionFields, unconstrainedDimensionDefinitions, internalGetGeometry(index), compareOp, nonSpatialCompareOp); }
private Geometry internalGetGeometry(final Index index) { final String indexCrsStr = getCrs(index.getIndexModel()); CrsCache cache = crsCodeCache.get(indexCrsStr); if (cache != null) { return cache.geometry; } cache = transformToIndex(indexCrsStr, index); crsCodeCache.put(indexCrsStr, cache); return cache.geometry; }
private CrsCache transformToIndex(final String indexCrsStr, final Index index) { if (crsMatches(crsCode, indexCrsStr) || (queryGeometry == null)) { final List<MultiDimensionalNumericData> constraints = super.getIndexConstraints(index); final Map<String, List<MultiDimensionalNumericData>> constraintsPerIndexId = new HashMap<>(); if (isDefaultCrs(indexCrsStr)) { indexCrs = GeometryUtils.getDefaultCRS(); } else { indexConstraintsFromGeometry(indexCrsQueryGeometry, index); final Map<String, List<MultiDimensionalNumericData>> constraintsPerIndexId = new HashMap<>();
private static boolean crsMatches(final String crsCode1, final String crsCode2) { if (isDefaultCrs(crsCode1)) { return isDefaultCrs(crsCode2); } else if (isDefaultCrs(crsCode2)) { return isDefaultCrs(crsCode1); } return crsCode1.equalsIgnoreCase(crsCode2); }
protected static Filter getFilter( final GeotoolsFeatureDataAdapter adapter, final ExplicitSpatialQuery delegateConstraints) { return GeometryUtils.geometryToSpatialOperator( delegateConstraints.getQueryGeometry(), adapter.getFeatureType().getGeometryDescriptor().getLocalName()); } }
private static String getCrs(final CommonIndexModel indexModel) { if (indexModel instanceof CustomCrsIndexModel) { if (isDefaultCrs(((CustomCrsIndexModel) indexModel).getCrsCode())) { return null; } return ((CustomCrsIndexModel) indexModel).getCrsCode(); } return null; }
@Override public QueryConstraints build() { if ((crsCode != null) && (geometry == null)) { LOGGER.warn( "CRS code `" + crsCode + "` cannot be applied without a geometry. Ignoring CRS."); } if ((spatialCompareOp != null) && (geometry == null)) { LOGGER.warn( "Spatial compare operator `" + spatialCompareOp.name() + "` cannot be applied without a geometry. Ignoring compare operator."); } if (geometry != null) { // its at least spatial if (timeRanges.length > 0) { // its spatial-temporal return new SpatialTemporalQuery( new ExplicitSpatialTemporalQuery(timeRanges, geometry, crsCode, spatialCompareOp)); } return new SpatialQuery(new ExplicitSpatialQuery(geometry, crsCode, spatialCompareOp)); } else if (timeRanges.length > 0) { // its temporal only return new TemporalQuery(new ExplicitTemporalQuery(timeRanges)); } return new EverythingQuery(); } }
@Override public byte[] toBinary() { final byte[] crsBinary = isDefaultCrs(crsCode) ? new byte[0] : StringUtils.stringToBinary(crsCode); final byte[] superBinary = super.toBinary(); final byte[] geometryBinary = new TWKBWriter().write(queryGeometry); final ByteBuffer buf = ByteBuffer.allocate( superBinary.length + geometryBinary.length + crsBinary.length + VarintUtils.unsignedIntByteLength(compareOp.ordinal()) + VarintUtils.unsignedIntByteLength(nonSpatialCompareOp.ordinal()) + VarintUtils.unsignedIntByteLength(crsBinary.length) + VarintUtils.unsignedIntByteLength(superBinary.length)); VarintUtils.writeUnsignedInt(compareOp.ordinal(), buf); VarintUtils.writeUnsignedInt(nonSpatialCompareOp.ordinal(), buf); VarintUtils.writeUnsignedInt(crsBinary.length, buf); VarintUtils.writeUnsignedInt(superBinary.length, buf); buf.put(crsBinary); buf.put(superBinary); buf.put(geometryBinary); return buf.array(); }
return new SpatialQuery(new ExplicitSpatialQuery(filterGeometry, crsCode));
new GeometryFactory().toGeometry(new Envelope(west, south, east, north)); query = new ExplicitSpatialQuery(bbox); new GeometryFactory().toGeometry(new Envelope(west, south, east, north)); query = new ExplicitSpatialQuery(bbox); } else { System.err.println("USAGE: storename --splits min max --bbox west south east north");
private BasicQuery composeQuery( final GeoConstraintsWrapper geoConstraints, final Constraints temporalConstraints) { // TODO: this actually doesn't boost performance much, if at // all, and one key is missing - the query geometry has to be // topologically equivalent to its envelope and the ingested // geometry has to be topologically equivalent to its envelope // this could be kept as a statistic on ingest, but considering // it doesn't boost performance it may not be worthwhile // pursuing // if (geoConstraints.isConstraintsMatchGeometry()) { // return new BasicQuery( // geoConstraints.getConstraints().merge( // temporalConstraints)); // } // else { return new ExplicitSpatialQuery( geoConstraints.getConstraints().merge(temporalConstraints), geoConstraints.getGeometry(), GeometryUtils.getCrsCode( components.getAdapter().getFeatureType().getCoordinateReferenceSystem())); // } }
baseQuery = new ExplicitSpatialQuery(constraints, geometry, extractedCompareOp); } else { baseQuery = new ExplicitSpatialQuery( constraints, geometry,