Changes between Version 3 and Version 4 of FDORfc63


Ignore:
Timestamp:
05/17/12 13:26:03 (13 years ago)
Author:
danstoica
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc63

    v3 v4  
    2323== Overview ==
    2424
    25 This RFC is for ....
     25This RFC is for adding a in-memory Spatial Index to FDO Spatial project.
    2626
    2727== Motivation ==
     
    219219}}}
    220220
     221== Remarks ==
     222
     223The API proposes 3 modes. This provides maximum flexibility for various scenarios.
     224For mode #2 and #3 the client code has to implement a segment visitor in order to retrieve a segment from the geomtry.
     225
     226The actual implementation will be the R-tree implementation found under Sqlite provider and developed by Traian Stanev.
     227
    221228== How to use this API ==
    222229
    223 The following code illustrates how to
     230The following code illustrates how to use the Spatial Index and the spatial index iterator.
     231
     232
     233{{{
     234    FdoPtr<FdoSpatialIndex> si;
     235
     236    FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
     237 
     238    /*************************** Test Polygon *************************/
     239    FdoStringP geomText = L"POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0), (1 1, 2 2, 2 1, 1 1), (3 3, 4 4, 4 3, 3 3))";
     240 
     241    FdoPtr<FdoIGeometry> geom = gf->CreateGeometry(geomText);
     242    FdoPtr<FdoByteArray> ba = gf->GetFgf(geom);
     243
     244    // Mode #1: FdoSpatialIndex_ByGeometriesBoundingBox
     245    si = FdoSpatialIndex::Create(FdoSpatialIndex_ByGeometriesBoundingBox);
     246
     247    // Insert the geometry
     248    si->InsertObject(777, ba);
     249
     250    // Query the SI
     251    FdoSpatialIndexIterator iter1(si, 1, 1, 2, 2);
     252
     253    FdoInt32 iPart, iSubpart, iSegment;
     254    FdoInt64 marker = 0;
     255
     256    // Get the results
     257    while (marker = iter1.GetNextObject())
     258    {
     259        FdoInt64 fid = marker; // not encoded
     260        // ... do stuff         
     261    }
     262       
     263    // Mode #2: FdoSpatialIndex_BySegmentsMultipleFeatures
     264    si = FdoSpatialIndex::Create(FdoSpatialIndex_BySegmentsMultipleFeatures);
     265    si->InsertObject(777, ba);
     266
     267    FdoSpatialIndexIterator iter2(si, 1, 1, 2, 2);
     268
     269    while (marker = iter2.GetNextObject())
     270    {
     271        FdoInt32 fid;
     272        si->DecodeMarker(marker, fid, iSegment);
     273        // ... do stuff
     274    }
     275       
     276    // Mode #3: FdoSpatialIndex_BySegmentsSingleFeature
     277    si = FdoSpatialIndex::Create(FdoSpatialIndex_BySegmentsSingleFeature);
     278    si->InsertObject(0, ba); // FeatId = 0
     279
     280    FdoSpatialIndexIterator iter3(si, 1, 1, 2, 2);
     281
     282    while (marker = iter3.GetNextObject())
     283    {
     284        si->DecodeMarker(marker, iPart, iSubpart, iSegment);
     285        // ... do stuff
     286    }
     287}}}
    224288
    225289== Managed FDO API ==