views:

42

answers:

0

I'm using the MapX 5.0 ActiveX plugin in an MFC application. I've got some temporary layers that I create in the following way:

// Create a new Fields Object
CMapXFields fields;
fields.CreateDispatch(fields.GetClsid());
// Create the field definitions for the new layer.

// Storing 64bit integers here. Is this even possible, btw?
fields.AddIntegerField("Timestamp", TRUE /*=> field gets indexed*/); 
VARIANT varFields;
varFields.vt = VT_DISPATCH;
varFields.pdispVal = fields.m_lpDispatch;

CMapXLayerInfo info;
info.CreateDispatch(info.GetClsid());
info.SetType(miLayerInfoTypeTemp);

info.AddParameter("Name", COleVariant(entry.second));
info.AddParameter("Fields", varFields);
// Don't write to disk
info.AddParameter("TableStorageType", COleVariant("memtable"));

m_map.GetLayers().Add(info.m_lpDispatch);

With about 18k features in a layer, the following takes about a minute on a 2GHz Quad Core with 3GB of memory...

// Search all features with a timestamp between leftTime and rightTime
time_t leftTime, rightTime;
// [set timestamps]

CString whereBetweenLeftAndRight;
whereBetweenLeftAndRight.
    Format(_T("Int(%I64d) <= Int(Timestamp) AND Int(Timestamp) <= Int(%I64d)"),
        leftTime, rightTime);
CMapXFeatures features(layer.Search(whereBetweenLeftAndRight)); // <- Slowtrocity

With the "Timestamp" field being indexed this should be a piece of cake using a binary search...

What am I doing wrong?
Or is this thing really always that slow? If yes, how can I work around that?