question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support samples along a path

See original GitHub issue

The google maps api lets you sample along a path. I don’t have plans to support this any time soon in Open Topo Data, but a user submitted a patch for v1.5.0 to add this functionality!

Update 2021-09-04: The patch below has some issues, here’s a better method that I’m adding: Sampling points along a lat,lon path

Old patch
--- opentopodata.orig/api.py	2021-03-10 16:36:58.761755648 +0100
+++ opentopodata/api.py	2021-03-21 09:43:48.369460334 +0100
@@ -190,6 +190,44 @@
         return _parse_polyline_locations(locations, max_n_locations)
 
 
+def _create_path_with_samples(lats, lons, samples):
+    """Create a path with the requested samples starting from given path
+
+
+    Args:
+        lats: The latitudes
+        lons: The longitudes
+        samples: Number of point in the segments of the path.
+
+    Returns:
+        lats: List of latitude floats.
+        lons: List of longitude floats.
+    """
+
+    if(len(lats) < 2):
+        return lats, lons
+    if(int(samples) < 2):
+        samples = 2;
+    lats1 = []
+    lons1 = []
+    lat1 = lats[0]
+    lon1 = lons[0]
+    for i in range(1, len(lats)):
+        lat2 = lats[i]
+        lon2 = lons[i]
+        dlat = (lat2 - lat1) / (int(samples) - 1)
+        dlon = (lon2 - lon1) / (int(samples) - 1)
+        lat = lat1
+        lon = lon1
+        for i in range(0, int(samples)):
+            lats1.append(lat)
+            lons1.append(lon)
+            lat += dlat
+            lon += dlon
+
+    return lats1, lons1
+
+
 def _parse_polyline_locations(locations, max_n_locations):
     """Parse and validate locations in Google polyline format.
 
@@ -399,6 +437,11 @@
             request.args.get("locations"), _load_config()["max_locations_per_request"]
         )
 
+        samples = request.args.get("samples")
+        if not samples:
+            samples = 2
+        lats, lons = _create_path_with_samples(lats, lons, samples)
+
         # Get the z values.
         datasets = _get_datasets(dataset_name)
         elevations, dataset_names = backend.get_elevation(

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bluthencommented, Aug 31, 2021

LOS is line of sight I think. So if you are planning radio or free space optic networks, maybe other applications.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenPathSampling: A Python Framework for Path Sampling ...
The OpenPathSampling (OPS) package provides an easy-to-use framework to apply transition path sampling methodologies to complex molecular ...
Read more >
I-864 Affidavit of Support Sample for Green Card Sponsorships
In the Affidavit of Support sample, the sponsor has a household income of $89,650. Based on the table in the federal poverty guidelines, ......
Read more >
Animate an object to follow along a path - Adobe Support
Animate an object to follow along a path ... Paste paths into position keyframes and fine-tune the animation path. ... This sample file...
Read more >
Bayes Model Selection with Path Sampling - jstor
We provide a new method of Path Sampling (with Small Change) that works much better than standard ... on PS-SC provides stronger support...
Read more >
Showing Elevation Along a Path | Maps JavaScript API
Try Sample; Clone Sample. This example displays a graph that shows the elevation along a path drawn on the map. ... Ask for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found