PointRotationExpression Testing

Hi,

I was tested the PointRotationExpression option in latest MapWinGIS version 5.2.1, but I am not observed any rotation of point symbology on map. Please find below is my code sample and also adding the shapefile sample. Please suggest me on this.Test_Sample.zip (1.0 KB) Test_Sample

Sample Code:
MapWinGIS.Shapefile shapefile = new Shapefile();
shapefile.Open(“C:\Temp\Test_Sample.shp”);

                ShapeDrawingOptions options = shapefile.DefaultDrawingOptions;
                options.FillColor = utils.ColorByName(tkMapColor.Red);
                options.PointType = tkPointSymbolType.ptSymbolFontCharacter;
                options.FontName = "Arial";
                options.PointCharacter = Convert.ToInt16("66");
                options.PointSize = 12;
                options.PointRotationExpression = "rotation";
                shapefile.Categories.ApplyExpressions();
                shapefile.Save();
                axMap1.AddLayer(shapefile, true);

Regards,
P.Ramakrishna

Hello @ramkiponnam

I may be speaking out of ignorance, since I have not yet looked at these enhancements, but if it has been implemented as other ‘Expressions’, and assuming that ‘rotation’ is the name of a field in your Shapefile, then it may be that you simply have to include the name in square brackets, as

options.PointRotationExpression = "[rotation]";

since Expressions typically require field names in brackets.

Regards,
Jerry.

Hello @jerryfaust

I have checked in 2 ways (with square brackets and without brackets), but not seen any difference on symbology rotation.

Regards,
P.Ramakrishna

Hello @jerryfaust

I am checking the above case for below request.
[MWGIS-140] - Allow point-based shapes to be individually rotated based on a ‘Rotation’ field in the shapefile

Regards,
P.Ramakrishna

@Mathijs.Dumon, are you able to describe or show an example of how to use the PointRotationExpression.

I have also tried a few things and could not get it to work. Hopefully there is something simple we are overlooking.

Thank you.
Jerry.

Did you test this with a symbol marker? Rotation is not supporter for vector markers.

Oh also important: the angle needs to be in degrees, not radians

Hi @Mathijs.Dumon,

I have given rotation field values in degree. Could you please check my first post and also attached the code functionality and test shape file. Please provide a sample code. This will help us to test the functionality,

Note:

I have tested the same functionality with options.PointType = tkPointSymbolType.ptSymbolStandard;
and not succeeded.
Code:
MapWinGIS.Shapefile shapefile = new Shapefile();
shapefile.Open(“C:\Temp\Test_Sample.shp”);

                ShapeDrawingOptions options = shapefile.DefaultDrawingOptions;
                options.FillColor = utils.ColorByName(tkMapColor.Red);
                options.PointType = tkPointSymbolType.ptSymbolStandard;
                options.PointShape = tkPointShapeType.ptShapeArrow;
                options.PointRotationExpression = "[rotation]";
                shapefile.Categories.ApplyExpressions();
                shapefile.Save();
                axMap1.AddLayer(shapefile, true); 

Thank you

Regards,
Ramki

Dear Ramki,

To clarify further, this only works with ptSymbolPicture

Your example would become:

MapWinGIS.Shapefile shapefile = new Shapefile();
shapefile.Open(“C:\Temp\Test_Sample.shp”);
                ShapeDrawingOptions options = shapefile.DefaultDrawingOptions;
                options.FillColor = utils.ColorByName(tkMapColor.Red);
                options.PointType = tkPointSymbolType.ptSymbolPicture;
                options.Image = OpenMarker("c:/path/to/icon.png");
                options.PointRotationExpression = "[rotation]";
                shapefile.Categories.ApplyExpressions();
                shapefile.Save();
                axMap1.AddLayer(shapefile, true);

The OpenMarker method is defined in this example: https://www.mapwindow.org/documentation/mapwingis4.9/_mark_points_8cs-example.html#a7

Hi @Mathijs.Dumon,

[MWGIS-140] (linked [MWGIS-123]) request raised for TTF Fonts rotation based on field value( Same like esri). Previous versions works as given point rotation value applied for entire shape file. So, We requested to rotate the symbol based on the provided field value. Could you please check and provide the solution for vector markers(tkPointSymbolType.ptSymbolFontCharacter) also. This will very helpful feature for me and others also.

Thank you

Regards,
P.Ramakrishna

Hello @ramkiponnam, @Mathijs.Dumon

Mathjis, thanks for the sample. What tripped me up was having to call Categories.ApplyExpressions when I had not defined any Categories. But it does work now.

I had started work on this a while back since I was also wanting ESRI-like behavior. But my work was based strictly on a single rotation field rather than an expression. I can see the benefit of using Expressions in order to allow more complex algorithms.

So I just went through the new code and applied the rotation logic to the Font and Standard symbols as well, so now they can all rotate individually based on the Expression. I will apply those changes so that they can be in the new release.

Regards,
Jerry.

Hi @jerryfaust,

Thanks for your quick support and solution. I will wait for new release.

Thanks alot.

Regards,
P.Ramakrishna

Ok.

Changes have been checked-in and MWGIS-140 has been updated with my actions.

@Mathijs.Dumon, the PointRotationExpression (and any other API changes) should be added to the documentation.

@ramkiponnam, if you work with the ‘develop’ branch, you can get the latest and rebuild. Otherwise, I presume that @pmeems will create a new release candidate this week.

Thank you.
Jerry.

Hello @jerryfaust

Thanks for the quick solution and I have taken the latest code and build successfully. I have tested the functionality with latest ocx file and observed the TTF font symbology rotated as per provided field values.

Once again Thank you for your great support

Regards,
P.Ramakrishna

Hello @jerryfaust,

I’ve went over all of my commits and updated the docs as needed (changes comitted). The PointRotationExpression was already in there.

cheers,
Mathijs

Hello @jerryfaust,

I need some help and i don’t know whether the functionality available or not. We have observed the font symbology size not displaying depending upon map scale. The symbol size showing same in all zoom levels.
ScaleLabels function is available for Shapefile.Labels. When we set ScaleLabels as True then the label size will be shown depending on mapscale. Is there any same function available for Font symbology?
Please guide me on this observation.

Regards,
P.Ramakrishna

Thank you, @Mathijs.Dumon for your work on this feature.

Hello @Mathijs.Dumon,

Could you please help us on my above post. The scale functionality is required, because the symbol will display in same size in all zoom levels( not fixed size).

Thank you

Regards,
P.Ramakrishna

I don’t even think the other symbol types scale with the map scale - so why would the font symbol?

I’ve made a new feature request to track this:
https://mapwindow.atlassian.net/browse/MWGIS-226

Hi @Mathijs.Dumon,

Thanks for taking the request as new feature. You are correct, other symbols also not available the scaling option (only labels have the scale option). Actually I am created the symbols in TTF font format for Point features. So, I am asking for Font symbology scaling.

Regards,
P.Ramakrishna