Пример #1
0
        /// <summary>
        /// Builds a <see cref="SpatialStrategy"/> from configuration options.
        /// </summary>
        protected virtual SpatialStrategy MakeSpatialStrategy(Config config)
        {
            //A Map view of Config that prefixes keys with "spatial."
            var configMap = new DictionaryAnonymousHelper(config);

            SpatialContext ctx = SpatialContextFactory.MakeSpatialContext(configMap /*, null*/); // LUCENENET TODO: What is this extra param?

            //Some day the strategy might be initialized with a factory but such a factory
            // is non-existent.
            return(MakeSpatialStrategy(config, configMap, ctx));
        }
        private static SpatialContext Call(params String [] argsStr)
        {
            var args = new Dictionary <String, String>();

            for (int i = 0; i < argsStr.Length; i += 2)
            {
                String key = argsStr[i];
                String val = argsStr[i + 1];
                args.Add(key, val);
            }
            return(SpatialContextFactory.MakeSpatialContext(args));
        }
Пример #3
0
        /// <summary>
        /// Builds a <see cref="SpatialStrategy"/> from configuration options.
        /// </summary>
        protected virtual SpatialStrategy MakeSpatialStrategy(Config config)
        {
            //A Map view of Config that prefixes keys with "spatial."
            var configMap = new DictionaryAnonymousClass(config);

            // LUCENENET: The second argument was ClassLoader in Java, which should be made into
            // Assembly in .NET. However, Spatial4n currently doesn't support it.
            // In .NET it makes more logical sense to make 2 overloads and throw ArgumentNullException
            // if the second argument is null, anyway. So no need to change this once support has been added.
            // See: https://github.com/NightOwl888/Spatial4n/issues/1
            SpatialContext ctx = SpatialContextFactory.MakeSpatialContext(configMap /*, assembly: null*/);

            //Some day the strategy might be initialized with a factory but such a factory
            // is non-existent.
            return(MakeSpatialStrategy(config, configMap, ctx));
        }
Пример #4
0
        private static readonly double LUCENE_4464_distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;//DEFAULT 2.5%

        public NtsPolygonTest()
        {
            try
            {
                IDictionary <string, string> args = new Dictionary <string, string>();
                args.Put("spatialContextFactory",
                         typeof(Spatial4n.Core.Context.Nts.NtsSpatialContextFactory).AssemblyQualifiedName);
                ctx = SpatialContextFactory.MakeSpatialContext(args /*, getClass().getClassLoader()*/);
            }
            catch (TypeLoadException e) //LUCENENET TODO: Does this match NoClassDefFoundError ??
            {
                AssumeTrue("This test requires Spatial4n.Core.NTS: " + e, false);
            }

            GeohashPrefixTree grid = new GeohashPrefixTree(ctx, 11);//< 1 meter == 11 maxLevels

            this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
            ((RecursivePrefixTreeStrategy)this.strategy).DistErrPct = (LUCENE_4464_distErrPct);//1% radius (small!)
        }
Пример #5
0
        private static readonly double LUCENE_4464_distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;//DEFAULT 2.5%

        public NtsPolygonTest()
        {
            try
            {
                IDictionary <string, string> args = new Dictionary <string, string>
                {
                    ["SpatialContextFactory"] = typeof(NtsSpatialContextFactory).FullName
                };
                ctx = SpatialContextFactory.MakeSpatialContext(args, GetType().Assembly);
            }
            catch (Exception e) when(e.IsNoClassDefFoundError())
            {
                AssumeTrue("This test requires Spatial4n: " + e, false);
            }

            GeohashPrefixTree grid = new GeohashPrefixTree(ctx, 11);//< 1 meter == 11 maxLevels

            this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
            ((RecursivePrefixTreeStrategy)this.strategy).DistErrPct = (LUCENE_4464_distErrPct);//1% radius (small!)
        }