MapWinGIS Ax with dBase2019: unable to open files

Addendum
I omitted to specify that the shapefile concerns points for the city of Nantes - France.

Hello @Joseph

Well I have no trouble opening both the Shapefile and the Image; so there’s something else going on. I assume that DBase hands in the filename strings in the proper COM (BSTR) format? It would be interesting to test some other API function, such as a Label, to verify proper transmission of strings.

Even so, the points do not appear to be located properly. All of the x values (longitudes) are negative values (around -2), and I think they’re supposed to be positive for Paris.

Have you (or can you) download and install the MapWindow5 application? This is built using the OCX, so it can be used to load your data; to verify that the OCX is capable of loading the data, letting you know if something is wrong. So you can easily visualize it, reproject it, load imagery or Open Street Maps behind it, etc, to verify the integrity of the data. This is one of the tests I did to look at your points.

Let me know if you can do that, and what you see. I might try playing with it a little more.

Regards,
Jerry.

Loaded into MapWindow5, what I get is a strange wrap-around of the map tiles when I first load, then zoom way out. I don’t know whether our code is confused, or if Open Street Maps is confused (probably our code). But I can finally get imagery behind the points.

First I get this (see your points all stacked on the very right, purple dot in white space):

image

Then, after zooming out a bit, I get this (all your points are now shown in France):

image

After this, I can zoom back in again, but the tiles never reload properly:

image

I’m not sure what’s happening. Could be an issue with the Tile management code.

Hello Jerry,
Thanks for your feedback, my tests are progressing better!
I used Mapwindows (5.6.3), got the same results as you and took the opportunity to do a bit of learning about its features and found a lot of cool things that I would like to use with the OCX.
With axMap, things are much better with a WGS projection! But I need to learn more about the specifics of layers / shapefiles / labels … they have so many properties and functions that it takes time … I am finishing a program to facilitate our testing.
However, I found a workaround to mark locations using ‘pointSymbols’ by increasing their size (I would like to change color, transparency and use icons but did not yet find the right functions).
I also tried to add label with text to the shapeFile but I must go wrong, nothing is visible with the following dBase code:
cLabel = “some text …”
form.axMap.degreesToProj (nx, ny, lx, ly)
sf.Labels.AddLabel (cLabel, lx, ly, 0.0, -1)
I certainly missed something!
As we have more work for our clients it slows me down in my testing. I must therefore focus on the marking with symbols at first and learn more to manage labels to start an integration in our software.
This is where I am…
Kind regards
Joseph

For the label test (when you have opportunity), try the following.
It adds a label to the drawing layer using screen coordinates (independent of scale), 100 pixels from the top left corner.

cLabel = "some text..."
form.axMap.NewDrawing(0) // zero indicates tkDrawReferenceList.dlScreenReferencedList
form.axMap.DrawLabel(cLabel, 100, 100, 0)

Regards,
Jerry.

Hello Jerry,
I had a lot of work but still took the time to perform several tests which confirm my first observations:

  • Text strings are only recognized by axMap but not by APIs loaded with ‘oleAutoClient’
  • The ‘get_’ and ‘set_’ methods are not recognized,

So I have two questions:

  • Is it possible to check why text strings are rejected by the library modules when they are well recognized by the activex?
  • Is there a way to fix it?
    This would solve all the problems I experienced with external files.

At my stage of progress (very beginner!), I can already place shapes and symbols at managed coordinates, deal with size, color and transparency parameters and display labels according to your example. Unfortunately, the text is always centered and I did not find how to change that.

However, I have started to integrate simple positioning into our software and hope to go further soon!
Thanks again for your help
Kind regards
Joseph

Hello Jerry,
Having no news since my last post on September 24, I would like to know if the questions I asked are relevant enough to find solutions for a standard recognition of file name strings between AXmap and DLLs / APIs?
In the meantime, as I found workarounds to keep the use of MapWinGIS Ax in our software, I will limit myself to the functions accessible for the moment since they suit our first needs.
Thank you in advance for your feedback and suggestions.
Kind regards
Joseph

Hello Joseph.

I’m sorry for the long delay. I’m not sure why the behavior is different. Some differences may be dependent up on whether the strings are coming from the database or coming from your code.

I need to see more specific code examples showing the labels that do work vs. the labels that don’t work. Then I can compare the specific interfaces (between the OCX and the library API) and perhaps see why a string might be ‘interpreted’ differently.

Thank you.
Jerry.

Hello Jerry,
Concerning the strings that are not recognized in the same way between AXmap and APIs, I noticed that shapefile.SaveAsEx() function works fine! (3 files dbf,shp,shx are created). This is even more surprising!
How can a same filename string causes a different behaviour between loading and saving it ?

Labels issues: below is the code used to test label positioning (dBase syntax) from axMap and from label & shapefile APIs. Works only from the activex but perhaps I missed some specific parameters when using the APIs ?
Thanks again in advance for your help
Regards
Joseph
// ‘LblOption’ variable contains the 3 modes for the tests
cTxtLabel = “Test label text”
nRotation = 0
do case
case LblOption=“ax”
form.DrawHnd = form.axMap.NewDrawing(1)
form.axMap.DrawLabelEx(form.DrawHnd, cTxtLab, x, y, nRotation)
case LblOption=“lb”
form.objLabel = new oleAutoClient(“MapWinGIS.labels.1”)
form.objLabel.visible = true
form.objLabel.ScaleLabels = true
form.objLabel.addLabel(cTxtLab, x, y, nRotation, -1)
case LblOption=“sf”
form.objShFile = new oleAutoClientMapWinGIS.Shapefile.1")
form.objShFile.labels.visible = true
form.objShFile.labels.ScaleLabels = true
form.objShFile.labels.addLabel(cTxtLab, x, y, nRotation, -1)
endcase

Hello Joseph.

It was helpful seeing your code. I generally don’t do free-standing labels, instead using those associated with Shapes in a Shapefile. So I had to play a little to see how they would work in the different scenarios.

The following is the modified code, in Visual Basic .NET. I tried to generally adhere to your naming and structure.

    ' ‘LblOption’ variable contains the 3 modes for the tests
    Dim cTxtLab As String = “Test label text”
    Dim nRotation As Integer = 0
    Dim x As Double = 1
    Dim y As Double = 1
    Dim LblOption As String = "sf"
    Select Case LblOption
        Case "ax"
            Dim DrawHnd As Integer = AxMap1.NewDrawing(tkDrawReferenceList.dlSpatiallyReferencedList)
            AxMap1.DrawLabelEx(DrawHnd, cTxtLab, x, y, nRotation)
        Case "lb"
            Dim DrawHnd As Integer = AxMap1.NewDrawing(tkDrawReferenceList.dlSpatiallyReferencedList)
            Dim objLabel As Labels = AxMap1.get_DrawingLabels(DrawHnd)
            objLabel.Visible = True
            objLabel.AddLabel(cTxtLab, x, y, nRotation)
        Case "sf"
            ' create Shapefile '
            Dim objShFile As New Shapefile
            objShFile.CreateNew("", ShpfileType.SHP_POINT)
            AxMap1.AddLayer(objShFile, True)
            ' create and add Shape '
            ' (it seems that at least 1 shape has to exist in the Shapefile, or an exception is thrown) '
            Dim shp As New Shape
            shp.Create(ShpfileType.SHP_POINT)
            shp.AddPoint(x, y)
            objShFile.EditAddShape(shp)
            ' to do freestanding labels, they must be unsynchronized from the shapes '
            ' otherwise, you would add one label per shape, and the label follows the shape '
            objShFile.Labels.Synchronized = False
            objShFile.Labels.Visible = True
            objShFile.Labels.AddLabel(cTxtLab, x, y, nRotation, -1)
    End Select
    AxMap1.Redraw()

And they all displayed the label at coordinate (1, 1), just North of the equator and East of GMT.

image

Summary:

  1. the “ax” case works as expected, using the Drawing Labels.
  2. the “lb” case uses the Drawing Labels, just like the “ax” case. I found the sample here, where the Tooltips use a reference to the Drawing labels. It appears that the Labels class is just a wrapper around either the Drawing labels, Shapefile labels, or Image labels. They don’t do anything in and of themselves.
  3. finally, the “sf” case required a little extra work.
    a. The Shapefile must be created (as you did, but you also need the CreateNew call).
    b. The Shapefile must be added to the map, otherwise its labels won’t be visible on the map.
    c. There appears to be an internal requirement that at least one Shape exist in the Shapefile.
    d. Finally, for free-standing Labels, you must set Synchronized = False. Otherwise, there is an expected one-to-one relationship between Shapes and Labels.

Hope that helps.
Regards,
Jerry.

Hello Jerry,
Thanks a lot ! I followed your example and it works
However I noticed that label Latitude is shifted one degree less. Below is a screenshot of the result (red circle is city of Nantes, at 47.3514291, -1.5922029).
Label is placed at a latitude of 46.351 although the point is at 47.351 despite the fact that both use the same coordinates.
image
Is there another parameter or function I should use to retrieve the right coordinates for the label ?
Thanks again
Regards
Joseph

Hello.

I’m not sure what’s happening. Are these the Shapefile-based labels?

In my test case, if I set

    Dim x As Double = -120
    Dim y As Double = 40

and I use this for both the point and the label, I get this.

image

You can’t see the point because it is below the label.

Now I just add 1 (degree) to the label position, and I get this.

image

You can now see the point straight below the label, (presumably) 1 degree away.

It may be helpful if I could see your code again, if that’s alright.

However, IF you intend to generally have your labels associated with points, I recommend that you use Synchronized labels, because then you only have to position the point, and the label follows along.

Regards,
Jerry.

Hi Jerry,
Below is the code used for testing both sync modes by commenting / uncommenting the corresponding 2 lines (I kept your sample code commented for each adapted line).

  • The unsync mode uses addLabel() function with the point coordinates but still shifted (130 km lower).
    image
  • The Sync mode uses generate() function but no label appears.
cTxtLab = "Test label text"	// Dim cTxtLab As String = “Test label text”
nRotation = 0	// Dim nRotation As Integer = 0
// City of Nantes coordinates
x = -1.5541362	// Dim x As Double = 1
y = 47.2186371	// Dim y As Double = 1
objShFile = new oleAutoClient("MapWinGIS.Shapefile.1")	// Dim objShFile As New Shapefile
objShFile.CreateNewWithShapeID("", 1)	// objShFile.CreateNew("", ShpfileType.SHP_POINT)
form.AxMap.AddLayer(objShFile, True)	// AxMap1.AddLayer(objShFile, True)
// ' create and add Shape '
shp = new oleAutoClient("MapWinGIS.Shape.1")	//Dim shp As New Shape
shp.Create(1)	// shp.Create(ShpfileType.SHP_POINT)
shp.AddPoint(x, y)
objShFile.EditAddShape(shp)
objShFile.Labels.Visible = true
// Unsync. mode
objShFile.Labels.Synchronized = false
objShFile.Labels.AddLabel(cTxtLab, x, y, nRotation, -1)
// Sync. mode
//      objShFile.Labels.Synchronized = true
//      objShFile.Labels.generate(cTxtLab, 0, false)
form.AxMap.redraw()

Regards
Joseph

Addendum:
I noticed that when varying zoom labels become visible or hidden and I suppose it has something to do with label ‘visibility’ and/or shape bounds… (I have to check how those parameters are combined).
Anyway, my problem is the strange positioning of labels using the same point/shape coordinates.
With, of course, the issue concerning file names recognition in some cases (SF save) and not in others (SF open)…

This is already a very old post. But do you still have this issue?

It might be you’re using coordinates in the wrong projection. What might help is to set the GeoProjection after creating the shapefile.