Hi everyone.
There is a problem in MapWinGIS version 5.2.4 that I can’t upgrade to work with version 5.1.1
I use PostgreSQL + MapWinGIS, so I can’t provide a working code example. I’ll try to describe it.
I generate captions for a layer with polygons.
Labels are generated only on complex polygons consisting of 2 parts or more, on simple polygons in the form of a regular rectangle, as you can see, there is nothing.
And in version 5.1.1 everything works correctly.
Can you tell me what you can do to get around this drawback? Or is it a bug that needs to be fixed in the MapWinGIS source code?
Just so I understand, we’re talking about the numbers inside the building polygons, yes? It appears that that is the primary difference between the images. However, if that’s the case, it does not look like they are associated with complex polygons; it looks like those labels are within only a few of the basic polygons. So I wonder if I’m missing something. Please forgive me for asking, but is it possible that the three buildings having labels in the second image are the only buildings of type = 57?
Just as a follow-up, I will say that there were serious changes in the labeling in v5.2, in which a number of bugs were introduced, so I wouldn’t be surprised if this is another bug. We would just have to figure out how to expose it.
Hi Jerry. It’s very good that you answered, there will be a chance that it will be fixed someday.
In fact, there are no buildings of type = 57 in the pictures.
This is the private sector, as we say - one-story houses - or cottages. In this case, I need a category for labels, so that the labels appear on the map later, and do not load the map so much. These pictures show an area of the city with multi-storey residential buildings of 5 floors and 9 floors and there are no houses of type 57. But if you add a category, then the labels on the entire map disappear, the labels remain only for these types of buildings:
I have added a video where the same issue can be obtained in MapWindow 5.6.4. I have not found where to add a category for labels, but I get the same effect using other manipulations.
Well it seems like I should be able to set up a test to reproduce this, so I’ll work towards that. Note that I’m out-of-town from Friday through Monday, so I may not get to it until early next week, I’m sorry for that.
So no answer yet, but I made some headway. After spending quite some time reviewing the code as it relates to multi-part labeling, I wasn’t seeing anything obvious, particularly as it relates to OGR data sources rather than Shapefiles. And then I stepped back and read your postings again, and looked again at the video.
Interestingly, the video example does not have anything to do with label categories, but simply labeling an OGR data source. I found a polygon data source that is stored in SQL Server, and I am able to reproduce exactly what you are seeing in the video (no labels, then all labels, then multi-part labels only).
I’ve got to stop for now, but now that I am able to reproduce the problem, I should be able to debug within the OCX, and hopefully find the breakdown.
When one of the developers was adding ‘caching’ to the label positioning, they made a typo.
Notice that both x and y are being set to labelX. So the labels were not being drawn because they were far outside of the viewport.
Regarding the three scenarios in your video, I can’t yet explain all of the behavior:
The first time setting up labels (through MapWindow5), the x and y are both zero, so that is why no labels are displayed. I will try to figure out if this is a bug in MapWindow, or as a result of the positional caching.
The third time through, when they were only being displayed on multi-part shapes; I’m guessing that it falls through different code than this bug; but I will have to do more investigation. Note that with this code fix, the labels are reliably displayed on all shapes even after repeatedly clearing and resetting the Labels.
Finally, I don’t yet know why this is not a bug in Shapefiles. That likewise will require additional debugging.
But that’s for another night. Either way, I will write up a Jira ticket and submit a code change for this bug.
Please let me know how testing goes, as I could not test your specific code case, and there may be additional changes required.
I should also note what I have learned regarding 2 of the unknowns I listed in note 10/12 above.
Regarding the first item, labels not appearing the first time through, I believe is due to a bug in MapWindow, when calling GenerateLabels for the first time, passes in label-placement constant lpNone, while all subsequent calls pass in lpCentriod.
Regarding the third item, that this only occurs for OGR-based data, is because OGR datasources retain a working Shapefile in memory, and can therefore retain cached values. Shapes from disk-based Shapefiles are read differently, creating a new Shape object for each read, thus losing any previously cached values.
Hello Jerry.
I tested the changes made. Now everything works as it did in version 5.1. Labels are displayed correctly, even with the addition of categories. Thank you very much for the work done.
P.S.
If you will let me, I would like to post messages about the errors found in version 5.2. I find some more while developing my applications.