Hi,
 
I am using MapX v4.0 with Visual C++ 6.
 
My goal is to create a layer containing a very large number of symbol features, representing a vehicle track.
 
I have tried this using Layer.AddFeature but this is far too slow for the number of features I'm talking about,
ie 1000s. It takes 24 seconds to add 1000 symbol features using the Layer.AddFeature method. My development
machine is a 500MHz Pentium III, with a big hard disk, WinNT v4 SP3 and 128 Mb of memory.
 
So I am trying to use the add dataset method instead. I am creating a text file containing track data for a single vehicle using the following format:
 
"\"1\"\t51.3256982342112740\t-2.9519214502039381\r\n"
"\"2\"\t51.3256982342112740\t-2.9519214502039381\r\n";
 
This is the same as in the mapx sample app that comes with MapX4. My unique identifier for each row is column 1. Longitude is column 2 and Latitude is column 3.
 
I have modified the code from the map sample app and I have included this at the end of this email.
 
When I run this code I get the following error: (caused by a COleDispatchException)
 
    "Unable to complete this type of bind with the reference column(s) specified"
 
 
Even if I got this working, how do I specify that I require a particular symbol feature at each point in the new layer?
 
 
Any assistance would be greatly appreciated.
 
 
 
Mark Jones
Saturn Technologies Ltd.
Ringwood
Hants
UK
 
 
 
// get the filename from the file open dialog
// the file must be in the format described above
void CTestMapXView::OnMapAdddata()
{
 HGLOBAL hGlobalData=NULL;
 char *psz=NULL;
 
 CFileDialog dlgFile(TRUE, "*.txt", NULL, 0, szDataFilter, this);
 
 if (dlgFile.DoModal() == IDCANCEL)
  return;
 
 // read file into a string, and copy it to a global  memory buffer
  CFile fileData(dlgFile.GetPathName(), CFile::modeRead);
  CString strBuffer;
  fileData.Read(strBuffer.GetBuffer(fileData.GetLength() + 1), fileData.GetLength()); 
 strBuffer.ReleaseBuffer(fileData.GetLength() + 1);
  fileData.Close();
 
 hGlobalData = GlobalAlloc(GMEM_MOVEABLE, strBuffer.GetLength()+1);
 psz=(char *)GlobalLock(hGlobalData);
 strcpy(psz, strBuffer);
 GlobalUnlock(hGlobalData);
 
 // Initialise the BindLayer object
 CMapXBindLayer BindLayer;
 BindLayer.CreateDispatch(BindLayer.GetClsid());
 
 BindLayer.SetKeyLength(7);
 BindLayer.SetLayerType(miBindLayerTypeXY);
 BindLayer.SetLayerName("Trail");
 BindLayer.SetRefColumn1(COleVariant((BYTE)2));   // Longitude stored in field 2
 BindLayer.SetRefColumn2(COleVariant((BYTE)3));   // Longitude stored in field 3
 
 VARIANT vBindLayer;                 
 vBindLayer.vt = VT_DISPATCH;
 vBindLayer.pdispVal = BindLayer.m_lpDispatch;
 
 // set the name of our dataset
 COleVariant vDataSetName("TestData");
 
 // set geofield
 COleVariant vGeoField((BYTE)1);           // Set geofield to field 1
 
 // set up source data - no error checking on alloc
 short Type = miDataSetGlobalHandle;
 VARIANT SourceData;
 SourceData.vt = VT_I4;
 SourceData.lVal = (long)hGlobalData;
 
 try
 {
  // now add the dataset to the datasets collection
  CMapXDataset ds = m_ctrlMapX.GetDatasets().Add(Type, SourceData, vDataSetName, vGeoField,
              COptionalVariant(), vBindLayer, COptionalVariant(), COptionalVariant());
 }
 catch (COleDispatchException *e)
 {
  e->ReportError();
  e->Delete();
 }
 catch (COleException *e)
 {
  e->ReportError();
  e->Delete();
 }
}

Reply via email to