MapWinGIS - MSAccess as a PointLayer?

Hi Folks

I am using MapWinGIS 4.9 in Delphi XE5 on Win 10 Pro 64 bit (but using 32 bit version of MapWinGIS). Using Office 365 32-bit edition. I am happy adding and styling Shapefile layers.

I would like advice please on whether it is possible to add/create a layer in MapWinGIS based on ID,Name, X & Y from a table of points in an MS Access table?

Any help gratefully received

Best regards
James

Hello @JDN

Generally speaking, layers loaded through any of the database drivers expect to find a ‘geometry’ field, rather than individual X and Y coordinates. On the other hand, Shapes can certainly be created based on the X,Y coordinates, including to an in-memory shapefile, separate from the database. Could you be more specific? Is this a one-time load of data? or is it a table that is continuously updated with X and Y values that you would like to load as points?

Regards.
Jerry.

Hi Jerry

Thanks for the reply. The backend DB will be relatively “stable” in the sense that the point names and X/Y coordinates shouldn’t change once set, but (there’s always a but) this cannot be guaranteed as the DB is shared and available for editing.

Could I create a new/temporary point shapefile based on the DB info for use in the user session just in case the DB changes between sessions? If so how would that be achieved using MapWinGIS in Delphi, if I have “Name”, “X” and “Y” for each point?

Again many thanks
Best regards
James

Please have a look at this example: CreatePointShapefile.cs

Hi Paul

Thanks for the details. Looks straightforward.

My thing is how to create a directly associated attribute table to store the point Name, and possibly other data from the backend access DB such as the X and Y data, Type of point, etc.?

Thanks
James

You can use the Table class of the Shapefile object to add fields and use Shapefile.EditCellValue() to get or set the value.

Here are some examples:

Hi Paul

I suppose that once I have created my point shapefile I can create attribute table fields using this kind of code…

“fieldIndex = sf.EditAddField(“MyDoubleValue”, FieldType.DOUBLE_FIELD, 10, 3);”
“fieldIndex = sf.EditAddField(“MyOtherDoubleValue”, FieldType.DOUBLE_FIELD, 8, 4);”

… etc. ?

Basically I need to add a “PointName” field (Text/string) and others will be double precision numbers.

Thanks
James

Yes, that is the correct workflow.
You could also create the shapefile once and only recreate it when the data in your db is changed.

Thanks Paul

Yes that’s the plan!

I might get some time over the coming weekend to play with this some more. The hardest bit is translating from C# to Object Pascal/Delphi!

Cheers
James