示例#1
0
        private static SpatialContext MakeCtx()
        {
            SpatialContextFactory factory = new SpatialContextFactory();

            factory.wktShapeParserClass = typeof(MyWKTShapeParser);
            return(factory.NewSpatialContext());
        }
示例#2
0
        public virtual void TestRectIntersect()
        {
            SpatialContext ctx = new SpatialContextFactory()
            {
                geo = false, worldBounds = new Rectangle(-100, 100, -50, 50, null)
            }.NewSpatialContext();

            new ShapeCollectionRectIntersectionTestHelper(ctx).TestRelateWithRectangle();
        }
示例#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 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));
        }
示例#5
0
        private void SetupCtx2D(SpatialContext ctx)
        {
            if (!ctx.IsGeo)
            {
                ctx2D = ctx;
            }
            //A non-geo version of ctx.
            SpatialContextFactory ctxFactory = new SpatialContextFactory
            {
                IsGeo       = false,
                WorldBounds = ctx.WorldBounds
            };

            ctx2D = ctxFactory.CreateSpatialContext();
        }
示例#6
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));
        }
示例#7
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!)
        }
示例#8
0
        private void SetupQuadGrid(int maxLevels)
        {
            //non-geospatial makes this test a little easier (in gridSnap), and using boundary values 2^X raises
            // the prospect of edge conditions we want to test, plus makes for simpler numbers (no decimals).
            SpatialContextFactory factory = new SpatialContextFactory
            {
                IsGeo       = false,
                WorldBounds = new Rectangle(0, 256, -128, 128, null)
            };

            this.ctx = factory.CreateSpatialContext();
            //A fairly shallow grid, and default 2.5% distErrPct
            if (maxLevels == -1)
            {
                maxLevels = randomIntBetween(1, 8);//max 64k cells (4^8), also 256*256
            }
            this.grid     = new QuadPrefixTree(ctx, maxLevels);
            this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
        }
示例#9
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!)
        }
示例#10
0
 //This constructor is mandated by SpatialContextFactory
 public BinaryCodec(SpatialContext ctx, SpatialContextFactory factory)
 {
     this.ctx = ctx;
 }
示例#11
0
 /// <summary>
 /// This constructor is required by <see cref="SpatialContextFactory.MakeWktShapeParser(SpatialContext)"/>.
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="factory"></param>
 public WktShapeParser(SpatialContext ctx, SpatialContextFactory factory)
 {
     this.m_ctx = ctx;
 }
示例#12
0
 public MyWKTShapeParser(SpatialContext ctx, SpatialContextFactory factory)
     : base(ctx, factory)
 {
 }