public IEnumerable <IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { if (string.IsNullOrEmpty(shapeWKT)) { return(Enumerable.Empty <IFieldable>()); } if (maxTreeLevel == 0) { switch (spatialSearchStrategy) { case SpatialSearchStrategy.GeohashPrefixTree: maxTreeLevel = 9; // about 2 meters, should be good enough (see: http://unterbahn.com/2009/11/metric-dimensions-of-geohash-partitions-at-the-equator/) break; case SpatialSearchStrategy.QuadPrefixTree: maxTreeLevel = 25; // about 1 meter, should be good enough break; default: throw new ArgumentOutOfRangeException("spatialSearchStrategy"); } } var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel)); var shape = SpatialIndex.ReadShape(shapeWKT); return(strategy.CreateIndexableFields(shape) .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.WriteShape(shape), Field.Store.YES, Field.Index.NO), })); }
public IEnumerable <IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { var spatialField = GetSpatialField(fieldName, spatialSearchStrategy, maxTreeLevel); return(spatialField.CreateIndexableFields(shapeWKT)); }
public static SpatialStrategy CreateStrategy(string fieldName, SpatialSearchStrategy spatialSearchStrategy, int maxTreeLevel) { switch (spatialSearchStrategy) { case SpatialSearchStrategy.GeohashPrefixTree: return new RecursivePrefixTreeStrategyThatSupportsWithin(new GeohashPrefixTree(Context, maxTreeLevel), fieldName); case SpatialSearchStrategy.QuadPrefixTree: return new RecursivePrefixTreeStrategyThatSupportsWithin(new QuadPrefixTree(Context, maxTreeLevel), fieldName); } return null; }
public static SpatialStrategy CreateStrategy(string fieldName, SpatialSearchStrategy spatialSearchStrategy, int maxTreeLevel) { switch (spatialSearchStrategy) { case SpatialSearchStrategy.GeohashPrefixTree: return(new RecursivePrefixTreeStrategyThatSupportsWithin(new GeohashPrefixTree(Context, maxTreeLevel), fieldName)); case SpatialSearchStrategy.QuadPrefixTree: return(new RecursivePrefixTreeStrategyThatSupportsWithin(new QuadPrefixTree(Context, maxTreeLevel), fieldName)); } return(null); }
public IEnumerable <IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { if (maxTreeLevel == 0) { maxTreeLevel = GeohashPrefixTree.GetMaxLevelsPossible(); } var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel)); var shape = SpatialIndex.ShapeReadWriter.ReadShape(shapeWKT); return(strategy.CreateIndexableFields(shape) .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.ShapeReadWriter.WriteShape(shape), Field.Store.YES, Field.Index.NO), })); }
public static SpatialOptions FromLegacy(SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0) { var factory = new GeographySpatialOptionsFactory(); SpatialOptions options; switch (spatialSearchStrategy) { case SpatialSearchStrategy.QuadPrefixTree: options = factory.QuadPrefixTreeIndex(maxTreeLevel); break; default: options = factory.GeohashPrefixTreeIndex(maxTreeLevel); break; } return options; }
public static SpatialOptions FromLegacy(SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0) { var factory = new GeographySpatialOptionsFactory(); SpatialOptions options; switch (spatialSearchStrategy) { case SpatialSearchStrategy.QuadPrefixTree: options = factory.QuadPrefixTreeIndex(maxTreeLevel); break; default: options = factory.GeohashPrefixTreeIndex(maxTreeLevel); break; } return(options); }
public SpatialField GetSpatialField(string fieldName, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0) { return(SpatialFields.GetOrAdd(fieldName, s => { if (SpatialFields.Count > 1024) { throw new InvalidOperationException("The number of spatial fields in an index is limited to 1,024"); } SpatialOptions opt; indexDefinition.SpatialIndexes.TryGetValue(fieldName, out opt); if (opt == null) { opt = SpatialOptionsFactory.FromLegacy(spatialSearchStrategy, maxTreeLevel); } return new SpatialField(fieldName, opt); })); }
/// <summary> /// Generates a spatial field in the index, generating a Point from the provided lat/lng coordinates /// </summary> /// <param name="fieldName">The field name, will be used for querying</param> /// <param name="shapeWKT">The shape representation in the WKT format</param> /// <param name="strategy">The spatial strategy to use</param> /// <param name="maxTreeLevel">Maximum number of levels to be used in the PrefixTree, controls the precision of shape representation.</param> /// <returns></returns> public static object SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy strategy, int maxTreeLevel) { throw new NotSupportedException("This method is provided solely to allow query translation on the server"); }
public IEnumerable<IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { if (string.IsNullOrEmpty(shapeWKT)) return Enumerable.Empty<IFieldable>(); if (maxTreeLevel == 0) { switch (spatialSearchStrategy) { case SpatialSearchStrategy.GeohashPrefixTree: maxTreeLevel = 9; // about 2 meters, should be good enough (see: http://unterbahn.com/2009/11/metric-dimensions-of-geohash-partitions-at-the-equator/) break; case SpatialSearchStrategy.QuadPrefixTree: maxTreeLevel = 25; // about 1 meter, should be good enough break; default: throw new ArgumentOutOfRangeException("spatialSearchStrategy"); } } var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel)); var shape = SpatialIndex.ReadShape(shapeWKT); return strategy.CreateIndexableFields(shape) .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.WriteShape(shape), Field.Store.YES, Field.Index.NO), }); }
public IEnumerable<IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { if (maxTreeLevel == 0) maxTreeLevel = GeohashPrefixTree.GetMaxLevelsPossible(); var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel)); var shape = SpatialIndex.ShapeReadWriter.ReadShape(shapeWKT); return strategy.CreateIndexableFields(shape) .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.ShapeReadWriter.WriteShape(shape), Field.Store.YES, Field.Index.NO), }); }
public IEnumerable<IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { if (maxTreeLevel == 0) maxTreeLevel = 9; // about 2 meters, should be good enough (see: http://unterbahn.com/2009/11/metric-dimensions-of-geohash-partitions-at-the-equator/) var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel)); var shape = SpatialIndex.ReadShape(shapeWKT); return strategy.CreateIndexableFields(shape) .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.WriteShape(shape), Field.Store.YES, Field.Index.NO), }); }
public SpatialField GetSpatialField(string fieldName, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0) { return SpatialFields.GetOrAdd(fieldName, s => { if (SpatialFields.Count > 1024) throw new InvalidOperationException("The number of spatial fields in an index is limited to 1,024"); SpatialOptions opt; indexDefinition.SpatialIndexes.TryGetValue(fieldName, out opt); if (opt == null) opt = SpatialOptionsFactory.FromLegacy(spatialSearchStrategy, maxTreeLevel); return new SpatialField(fieldName, opt); }); }
public IEnumerable<IFieldable> SpatialGenerate(string fieldName, string shapeWKT, SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree, int maxTreeLevel = 0, double distanceErrorPct = 0.025) { var spatialField = GetSpatialField(fieldName, spatialSearchStrategy, maxTreeLevel); return spatialField.CreateIndexableFields(shapeWKT); }