Navigation to a allocation with an Existing Latitude and Longitude

Discussions about CSEntry
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Navigation to a allocation with an Existing Latitude and Longitude

Post by Yass »

Hi Cspro Team,

There is a Listing Data that have a Latitude and Longitude information , Would want to use this data to send enumerator to the area using google map,

Please how do I go around it, even if navigation is not possible since Cspro is not a native map app ,how can i display the current location and an existing location both on Google Map.

Thanks
sherrell
Posts: 406
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by sherrell »

Hi Yass,

Have you seen the two examples of mapping that come with the CSPro installation? They can be found in these two folders:

C:\Users\<userName>\Documents\CSPro\Examples 7.6\1 - Data Entry\Listing with Map
C:\Users\<userName>\Documents\CSPro\Examples 7.6\1 - Data Entry\Listing Menu with Map

Ideally you want to use the 'map' object to create your map, then add items to it, then 'show' it. You should read through this page and the supporting pages on the map help to become familiar with it:

https://www.csprousers.org/help/CSPro/map.html

Below is a not-necessarily-elegant way of achieving what you want:
PROC GLOBAL

map
myMap;
numeric markerId;

PROC HOUSEHOLD
preproc

    // add the current HH's lat/long coordinates to the map

   
markerId = myMap.addMarker(HH_Latitude, HH_Longitude);
    myMap.setMarkerText (markerId, HH_NAME_OF_HEAD);

    // Attempt to get the interviewer's position

   
gps(open);          // on Android
   
if gps(read,5) then // a successful attempt at a read, for up to five seconds

        // add the interviewer's location to the map

       
markerId = myMap.addMarker(gps(latitude),gps(longitude));
        myMap.setMarkerText (markerId,
"Your Location");

   
else
        errmsg
("GPS signal could not be acquired");
   
endif;
   
gps(close);

    myMap.show();

As for giving instructions on how to go from point A to point B, that is not something we offer. This would involve a significant amount of map "awareness", as the software would need to be aware of rivers/fenced off areas/etc. that could not be easily traversed, if they could be traversed at all (for ex, military facilities that are off-limits to civilians). The interviewer will have to use the map to try and ascertain how to move from one point to another, based on the map provided.

Note that the mapping functions currently only run on Android. However, we will be releasing a new version in the next few weeks that will allow execution on Windows devices, allowing you to test your logic as you develop it.

Sherrell
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by Yass »

Thanks Sherrel.
Gregory Martin
Posts: 1845
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by Gregory Martin »

Will your enumerators have Internet access? If so, you can use Google Maps navigation. There is an example here:

https://www.csprousers.org/help/CSPro/s ... ction.html
google_maps_navigation.setArgument("data", "google.navigation:q=U.S.+Census+Bureau");
You would replace "U.S. Census Bureau" with the "latitude, longitude" of your location.
htuser
Posts: 638
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by htuser »

Another solution to navigate to an existing lat/long would be of using routing algorithms.

As Greg posted it, Google map implement routing.
But, in some developing countries, OpenMapStreet have better detailed data than Googlemap.

And, if you want offline routing, you must have your own route vector data or download them from Openmapstreet.
More, you must use some routing algorithms on your devices.
Hopefully with the future javascript<->cspro interoperability and the support of vector data on CSPro Map feature, you'll be able to use existing Javascript routing libraries in your application for routing.
https://leafletjs.com/plugins.html#routing

https://stackoverflow.com/questions/418 ... tom-points
https://github.com/bbecquet/jKstra
https://github.com/andrewhayward/dijkstra
a Youtube video of an example using Javascript: https://www.youtube.com/watch?v=F8dnYNTncoU
the source code for the video: https://github.com/ruvictor/map-app-directions (note this use a proprietary implementation of a javascript routing algorithm: mp-routing.js from Mapquest.)
(theses links are provided as illustration, but you can find better example on the web)

Maybe, the CSPro Developer Team may implement routing in the map feature natively in the future...

Best,
G.VOLNY, a CSProuser from Haiti, since 2004
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by Yass »

Thanks Greg and htuser
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by Yass »

Hi Sherrell is it a way to modify this code to find the location on an mbtiles?

Thanks

sherrell wrote: October 1st, 2021, 11:01 am Hi Yass,

Have you seen the two examples of mapping that come with the CSPro installation? They can be found in these two folders:

C:\Users\<userName>\Documents\CSPro\Examples 7.6\1 - Data Entry\Listing with Map
C:\Users\<userName>\Documents\CSPro\Examples 7.6\1 - Data Entry\Listing Menu with Map

Ideally you want to use the 'map' object to create your map, then add items to it, then 'show' it. You should read through this page and the supporting pages on the map help to become familiar with it:

https://www.csprousers.org/help/CSPro/map.html

Below is a not-necessarily-elegant way of achieving what you want:
PROC GLOBAL

map
myMap;
numeric markerId;

PROC HOUSEHOLD
preproc

    // add the current HH's lat/long coordinates to the map

   
markerId = myMap.addMarker(HH_Latitude, HH_Longitude);
    myMap.setMarkerText (markerId, HH_NAME_OF_HEAD);

    // Attempt to get the interviewer's position

   
gps(open);          // on Android
   
if gps(read,5) then // a successful attempt at a read, for up to five seconds

        // add the interviewer's location to the map

       
markerId = myMap.addMarker(gps(latitude),gps(longitude));
        myMap.setMarkerText (markerId,
"Your Location");

   
else
        errmsg
("GPS signal could not be acquired");
   
endif;
   
gps(close);

    myMap.show();

As for giving instructions on how to go from point A to point B, that is not something we offer. This would involve a significant amount of map "awareness", as the software would need to be aware of rivers/fenced off areas/etc. that could not be easily traversed, if they could be traversed at all (for ex, military facilities that are off-limits to civilians). The interviewer will have to use the map to try and ascertain how to move from one point to another, based on the map provided.

Note that the mapping functions currently only run on Android. However, we will be releasing a new version in the next few weeks that will allow execution on Windows devices, allowing you to test your logic as you develop it.

Sherrell
aaronw
Posts: 570
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by aaronw »

The CSPro 77 release which will be released soon has a GPS widget that allows the user to select a location on the map to capture the coordinates.
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by Yass »

Hi Cspro Team,

Am using the new CSPro version 7.7 and want use the GPS Widget but have no idea on how to do. I have
a reference file with xlatitude and lxongitude coordinates and will be taking another coordinate(ylat, xlong) in the main file.

Would like to plot these set of coordinates with different markers on a basemap or google map. Indicate the distance between the two
points.

The App have a menu that have the reference file with gps items (xlong, xlat) and main file with gps item (ylong, ylat) . the idea
is check if the Field Officer visited the right location.
htuser
Posts: 638
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Navigation to a allocation with an Existing Latitude and Longitude

Post by htuser »

Hi Yass,
I already doing this on the past, but without the map.
It's very easy so, i'm trying to add bearing for facilitate end users finding directions. And also, some offline routing using sample and explanation i posted early.
The dev team already implement an app with similar UI for distance calculation and direction finding. Here's the function they used for calculation.
function findClosestMetroStations()

    if gps(open) = 0 then
        errmsg
("The GPS unit on your device is turned off. Please turn it on before continuing."); 
        exit;
    endif;
   
   
    gps(read,120); // try to get a gps reading for up to 120 seconds
   
gps(close);

    numeric currentLat,currentLong;
   
    currentLat = gps(latitude);
    currentLong = gps(longitude);

    if special(currentLat) then
        errmsg
("No successful GPS reading could be obtained.");
        exit;
    endif;

    ctr = 1;
   
    // load all of the stations into our working storage dictionary
   
locate(STATIONS_DICT,>=,"");

    while loadcase(STATIONS_DICT) do
       
WS_STATIONS(ctr) = STATION_NAME;
        WS_DISTANCE(ctr) = gps(distance,currentLat,currentLong,LATITUDE,LONGITUDE) * metersPerMile;
        inc(ctr);
    enddo;

    sort(WS_REC using WS_DISTANCE); // sort by the distance of the station from the current location

   
show(WS_DICT.WS_REC,WS_STATIONS,WS_DISTANCE,title("Station","Distance (miles)"));
   
end;
It has been released 8 years ago. In the meantime, it can be re-write using newest functions.
If this is not sufficient, i can send the complete app to you.

Hope this help you,
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply