Beispiel #1
0
    public void SetSpatialFilterRect(Enyim.Collections.Envelope env)
    {
        currentenv = env;
        List <NoteData> lst = new List <NoteData>();

        spatialquery.Find(currentenv, false, ref lst);
    }
Beispiel #2
0
 internal void Extend(Envelope by)
 {
     X1 = Math.Min(X1, by.X1);
     Y1 = Math.Min(Y1, by.Y1);
     X2 = Math.Max(X2, by.X2);
     Y2 = Math.Max(Y2, by.Y2);
 }
Beispiel #3
0
    public int Find(Enyim.Collections.Envelope env, bool getdata, ref List <NoteData> lst)
    {
        int result = 0;
        var r      = tree.Search(env);

        if (getdata == true)
        {
            lst.Clear();
            foreach (var item in r)
            {
                lst.Add(item.Data.Data);
            }
            result = lst.Count;
        }
        else
        {
            lstFindResult.Clear();
            foreach (var item in r)
            {
                lstFindResult.Add(item.Data.Data);
            }
            result = lstFindResult.Count;
        }
        return(result);
    }
Beispiel #4
0
    void ReadFeature2Tree()
    {
        Envelope env = new Envelope();

        layer.GetExtent(env, 1);
        mapenv = new Enyim.Collections.Envelope(env.MinX, env.MinY, env.MaxX, env.MaxY);
        env.Dispose();


//         var layerdef = layer.GetLayerDefn();
//         var c = layerdef.GetFieldCount();
//         for (int i = 0; i < c; i++)
//         {
//             var fielddef = layerdef.GetFieldDefn(i);
//             System.Diagnostics.Debug.Assert(fielddef != null);
//
//
//             Debug.Log(fielddef.GetName());
//             Debug.Log(fielddef.GetTypeName());
//             Debug.Log(fielddef.GetWidth());
//         }


        layer.ResetReading();
        Feature feat;

        while ((feat = layer.GetNextFeature()) != null)
        {
//             var s = feat.GetFieldAsString("DLMCX");
//             Debug.Log(s);
            spatialquery.Insert(feat);
        }
    }
Beispiel #5
0
    public List <NoteData> SpatialQuery(CPPOGREnvelope env)
    {
        var r = new List <NoteData>();

        Enyim.Collections.Envelope e = new Enyim.Collections.Envelope(env.MinX, env.MinY, env.MaxX, env.MaxY);
        spatialquery.Find(e, true, ref r);
        return(r);
    }
Beispiel #6
0
    public static Rect ECEnvlope2Rect(Enyim.Collections.Envelope rc)
    {
        Rect r = new Rect();

        r.xMin = (float)rc.X1;
        r.yMin = (float)rc.Y1;
        r.xMax = (float)rc.X2;
        r.yMax = (float)rc.Y2;
        return(r);
    }
Beispiel #7
0
    Enyim.Collections.Envelope currentenv = null; // 当前view呈现的map范围


    public void Open(string fname)
    {
        Clear();
        ds = Ogr.Open(fname, 1);
        Assert.IsNotNull(ds);
        Assert.IsTrue(ds.GetLayerCount() > 0);
        layer = ds.GetLayerByIndex(0);
        Assert.IsNotNull(layer);


        spatialquery = new GisSpatialQuery();
        spatialquery.Clear();
        ReadFeature2Tree();
        currentenv = new Enyim.Collections.Envelope();
    }
Beispiel #8
0
    public bool Insert(Feature f)
    {
        bool     result = false;
        NoteData data   = new NoteData();

        data.fea = f;
        var geo = data.fea.GetGeometryRef();

        Assert.IsNotNull(geo);
        OSGeo.OGR.Envelope envogr = new OSGeo.OGR.Envelope();
        geo.GetEnvelope(envogr);
        Enyim.Collections.Envelope env = new Enyim.Collections.Envelope(envogr.MinX, envogr.MinY, envogr.MaxX, envogr.MaxY);
        envogr.Dispose();
        RTreeNode <NoteData> node = new RTreeNode <NoteData>(data, env);

        tree.Insert(node, env);
        result = true;
        return(result);
    }
Beispiel #9
0
 public static CPPOGREnvelope ECEnvlope2CPP(Enyim.Collections.Envelope rc)
 {
     return(new CPPOGREnvelope(rc.X1, rc.Y1, rc.X2, rc.Y2));
 }
Beispiel #10
0
 internal bool Intersects(Envelope b)
 {
     return b.X1 <= X2 && b.Y1 <= Y2 && b.X2 >= X1 && b.Y2 >= Y1;
 }
Beispiel #11
0
 internal bool Contains(Envelope b)
 {
     return X1 <= b.X1 && Y1 <= b.Y1 && b.X2 <= X2 && b.Y2 <= Y2;
 }
Beispiel #12
0
 public RTreeNode(T data, Envelope envelope)
 {
     Data     = data;
     Envelope = envelope;
     children = new Lazy <List <RTreeNode <T> > >(() => new List <RTreeNode <T> >(), LazyThreadSafetyMode.None);
 }