Multiple polygons in map viewer

Discussions about CSEntry
Post Reply
vgonzalez
Posts: 27
Joined: March 12th, 2020, 4:19 pm
Location: VENEZUELA

Multiple polygons in map viewer

Post by vgonzalez »

Greetings to all,

I wanted to ask all the programmers and developers who have worked with the map object if they have been able to load multiple polygons in the CSPro map viewer?

I am asking you because so far I have been able to create and load individual polygons into the CSPro Map Object without problems thanks to the CSPro examples, however, when I generate a multi-polygon file with QGIS and save it in .json format, no I was able to load it into the viewer.

Is there any parameter or option that allows to do it in version 7.3.3?

Or

Will it be considered in the new release?
htuser
Posts: 632
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Multiple polygons in map viewer

Post by htuser »

Hello VGonzalez,
I the past, I was able to load group of polygons in a CSPro map view and zoom on the last using the following functions:
Function string MapStore()
    string mapFolder=pathname(Application) + "MapVector/";
    exit mapFolder;
end;
Function loadAllSavedPolygons()
    listingMap.setTitle("Affichage les limites de toutes les grappes");
    listingMap.clearGeometry();
    geometry polygon;
    list string ClusterPolygon;
        dirlist(ClusterPolygon, MapStore(), "*geojson");

        string polygonFile;
    do numeric i = 1 while i <= ClusterPolygon.length()
        polygonFile= ClusterPolygon(i);

        numeric isLoaded = polygon.load(polygonFile);
        if isLoaded then
           
listingMap.addgeometry(polygon);
            listingMap.zoomTo(polygon.minLatitude(), polygon.minLongitude(), polygon.maxLatitude(), polygon.maxLongitude(), 15);
        endif;
    enddo;

        listingMap.show();

end;
Please let me know if this also work for you. If no, please use it in a small demo app and post it in the forum, so I will be able to help you in better way.
Best,
G.VOLNY, a CSProuser from Haiti, since 2004
vgonzalez
Posts: 27
Joined: March 12th, 2020, 4:19 pm
Location: VENEZUELA

Re: Multiple polygons in map viewer

Post by vgonzalez »

thank you for your answer htuser,

The way to load several .json files is very useful and functional, which helps me in a way to solve my problem with loading individual polygons, however, I wanted to go a little further, which is perhaps still very ambitious and it is load in a single file.

When creating a multi-polygon file in QGIS, this application stores all the polygons in a single file as can be seen in the following images.


Viewing the file in QGIS:
CreateFile.png
CreateFile.png (481.73 KiB) Viewed 6518 times

Internal structure of the file:
InFile.png
InFile.png (713.58 KiB) Viewed 6518 times
This case is what I wanted to know if it is possible or feasible to read and load in the CSPro Map Viewer

Thanks in advance for your recommendations.
htuser
Posts: 632
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Multiple polygons in map viewer

Post by htuser »

Hello VGonzalez,
I was able to launch multiple polygons using CSPro. Here's a working demo: https://github.com/gregvolny/CSPro-Demo ... tiPolygons
Hope the CSPro Developer Team will help us in having code colorizer for Github (as I requested it years ago: viewtopic.php?t=3612)
Please follow the steps in the following screens.
Screen_All.jpg
Screen_All.jpg (474.37 KiB) Viewed 6510 times
And let me know.
Any new and better way from the CSPro Developer Team is welcome. Mainly, I don't understand why I'm obliged to refresh the view after loading
Geojson files using the CSPro-JS API...
Best,
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply