What exactly are "levels" in polyline encoding/decoding? - google-maps-api-3

What are "levels" in polyline encoding/decoding, and exactly how do they relate to map zoom levels in Google Maps API v3 or Android Maps API v2?
The only description I can find is from the Interactive Polyline Encoder Utility:
Polylines in Google Maps are formed as a set of latitude/longitude pairs. In addition, for each vertex (location) in an encoded polyline, a level can be specified indicating that the location should appear on that level and any level higher (i.e. any decrease in zoom.). If a location does not appear on a given level, then the line will go from the last visible location to the next visible location. Note that the first and last locations must be Level 3 points, otherwise the polyline won't display on all levels.
Does "Level 3" correspond to a zoom level of 3 in the Google Maps API v3 or Android Maps API v2?
Here's what a zoom level of 3 looks like in the Google Maps API v3 (no polyline is displayed - this is simply to illustrate what the "zoom level = 3" looks like):
Should a "Level 3" point be displayed if we zoom out one step further, to zoom Level 2?
The quote:
Note that the first and last locations must be Level 3 points, otherwise the polyline won't display on all levels.
...seems to indicate that Level 3 points should be displayed on all levels, including zoom levels 2, 1, and 0.
I'm wondering if the statement:
...a level can be specified indicating that the location should appear on that level and any level higher (i.e. any decrease in zoom.)
...should actually be:
...a level can be specified indicating that the location should appear on that level and any level higher (i.e. any increase in zoom.)
"decrease in zoom" doesn't seem correct, because Level 18 (very zoomed in) points would be rendered on Level 3 (very zoomed out).
"increase in zoom" seems to generally make sense (you'd render a Level 3 zoomed out point also when you zoom in to Level 18 - in other words, you add detail as you zoom in closer to the map) - however, it seems to contradict the statement that Level 3 points should be rendered at lower zoom levels 2, 1, and 0.
On Android, the open-source android-maps-utils library includes a method to decode polylines, but it doesn't handle levels, so I can't tell if there is a readily-available mapping to Android Maps API v2 zoom levels.
Can anyone provide clarity on this?

Levels are an obsolete feature. They controlled whether points were visible at certain zoom levels. They were a significant feature of Google Maps API v2, but you should ignore them now; Google Maps API v3 does it automatically.

zoom level defines the resolution of the current view.
zoom level
0: to encompass the entire earth
1: World
5: Landmass/continent
10:City
15: Streets
20: Buildings
"zoom=12" isused in below exapmle
https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&key=YOUR_API_KEY&signature=YOUR_SIGNATURE

Related

Polygon comparison between layers

I'm trying to compare specific polygons between layers (different years), to see if there has been any change to the area. Eg[2021 & 2019]2019 & 2021 In this example (from left to right), A would decrease by the amount that is outside of the layer, as well as the amount that B is now taking instead. C would also increase in area.
The difference, symmetrical difference, union, and intersection tools all find areas outside the total bounding box of the layer, but cannot find changes to polygons within the layer.
My desired output is a change (either % or absolute) in area from each layer to a master layer (the latest year).
(Some polygons get split and/or renamed, however I suspect this is a small enough cohort that it can be addressed manually.)
Edit: Currently trying "Detect Dataset Changes", but the polygons don't exactly 100% overlap, the 0.00000001% changes in the border mess it up and mark every polygon as changed. Posted as new question: Is there a tolerance setting I can use with "detect dataset changes" tool?

Determine minimum number of "invisible squares" to cover all markers on a map?

I have a map full of markers corresponding to GPS coordinates, represented as a PostgreSQL + PostGIS database table using "geography" type for the GPS column.
Imagine, if you will, one semi-transparent square on top of each of these points corresponding to 1x1 mile, based from the centre, often intersecting with each other.
I'm trying to determine the minimum number of such "squares" and their GPS coordinates, so that they "cover" all of the markers with a minimum of 25 meters to the nearest border.
If it makes it any easier, the positions of these "squares" don't have to match the positions of any of the markers.
The purpose of this is to attempt to cut down the number of API requests to a "houses for sale" service significantly, since most of the positions are close to each other and the API takes a 1x1 mile square "bounding box" as the input for each call. It would be insanely wasteful to call the API many times for basically the same area when maybe 1 or 2 times would do it if I can first figure out where these imaginary "squares" go.
I get the feeling that this is considered a "known, common and solved" problem, but so far, I've not been able to figure out how to do it.
Sorry, but it seems like you have no idea what you are doing and are just being rude, both here and at PostGIS irc-channel.
You give no information about your api.
What is creating your maps?
Is it a wms-service or what?
What most people would do is setting up a mapservice with a tile cache. Then the mapservice will pich the tiles needed for each house you want to show ( or multiple houses).
The tiles will be prepared o will be created on the fly. But they will be cached for next time.
So, I think you should read up on things like
MapServer
Mapnik
MapCache
Mapproxy
GeoServer
That is not a complete list, but might give you some ideas about what it is that you want

What direction do the DICOM instance numbers grow along?

By direction I mean for example from a patient's head to bottom or from his bottom to head. The CHEST CT scans I have seen so far indicates that Instance Number 1 slice is usually the first one down from the upper part of the body but I don't know whether this is part of the standard or there are some other tags that I should inspect into to determine.
There is no rule in DICOM that requires the Instance Number to be related to the slice position in a particular way. The link of Bartloimiej shows that there is a rule how the slice coordinates defined by Image Position Patient (0020,0027) and Image Orientation Patient (0020, 0037) are related to directions in the patient's body (head, feet, etc.)
So if you want to apply spatial ordering, these attributes are what you want to use. Slice Location (0020,1041) will not help you as well:
C.7.6.2.1.2 [...] This information is relative to an unspecified implementation specific reference point.
For original (i.e. Image Type (0008,0008) is ORIGINAL\PRIMARY...) CT slices, it is quite safe to assume that some growth in the Z-Direction is always present in a volumetric dataset. But for MRI or for reconstructed CT-slices (MPR), you may find datasets in which slices are parallel to the xz or yz plane. If your application is supposed to handle such images, make sure to avoid division by zero...
Yes, the standard defines it. DICOM PS3.3, part C.7.6.2:
The direction of the axes is defined fully by the patient's orientation.
If Anatomical Orientation Type (0010,2210) is absent or has a value of BIPED, the x-axis is increasing to the left hand side of the patient. The y-axis is increasing to the posterior side of the patient. The z-axis is increasing toward the head of the patient.
There is also a tag (0020,0037), Image Orientation (Patient), which relates actual position of the patient to the global coordinate frame. In trunk CT it is almost always 1 0 0 0 1 0 (no rotation) and you don't need to deal with it. Otherwise, see comments under the link above.
You are correct. The chest CT series are sorted from head to feet. The slice closest to the head should have the lowest Instance Number.
I don't know if this is defined by the DICOM standard or not, but I have seen a lot of DICOM images and the convention is this:
AXIAL - sorted by Z axis high to low (head to feet)
CORONAL - sorted by Y axis high to low (back to front)
SAGITTAL - sorted by X axis low to high (right to left)
Notice in all cases, the first slice in the series will be farthest from the observer.
If you need to generate Instance Number, you should sort the images by the dot product of Image Position Patient and (1,-1,-1) from low to high. In the rare degenerate case (all dot products are the same), I don't know. Pick another direction to sort, but probably (0,-1,-1) would be a good choice.
EDIT: I just discussed this with a friend who is more experienced. He said it varies. Some departments prefer back to front order, some prefer front to back. Also some DICOM viewers will give users the choice of how the slices are sorted (by Instance Number, Slice Location, IPP, Content Time, etc)

Google Maps fractional zoom only works 3 times

Using Google Maps JavaScript API v3, it is possible to change the zoom of a map using the setZoom method, see the Map class.
I am able to set the zoom to a fractional value and it works, i.e. gmap.setZoom(1.1) works. However, it stops working on the 4th call with a fractionnal zoom, i.e.:
gmap.setZoom(1.1) works
gmap.setZoom(1.2) works
gmap.setZoom(1.3) works
gmap.setZoom(1.4) doesn't work, the map turns grey.
It's not the 1.4 value that doesn't work. Setting 1 then 1.4 does work. It really seems to be on the 4th time that we set a fractionnal value.
Is this a known bug or is there a way to avoid the map to turn grey after multiple zooming using fractionnal zooms?
I'm surprised it works ever. Fractional zoom levels are not supported. From the documentation:
zoom | Type: number
The initial Map zoom level. Required. Valid values: Integers between zero, and up to the supported maximum zoom level.
Related issues in the issue tracker:
Issue 10977: Bug: Zoom cannot be set to e.g. 6.5 initially - map is shown in gray color only
Issue 9948: Fractional zoom level(fine zoom)

how to know in which region is the markers using leaflet map

I want to the count of markers based on location using leaflet map
ie,
Say in india
Number of markers in bangalore
number of makers in mysore so on...
only thing i would think of to do this is using contains( point )
which is in the doc
But how to use it to find the maker is in that region as i will not be aware of the coordinates of the region
Is there a way to check like
region.contains(markerLatLang)
Leaflet .contains() works on L.LatLngBounds objects, which are actually a rectangular region. So it tells if your point / marker is within a rectangle or not.
You would need first to retrieve yourself the coordinates of your administrative areas of interest (India, etc.). See https://gis.stackexchange.com/questions/199765/where-to-get-world-wide-detailed-administrative-boundaries
BTW, a simple version of countries boundaries can be: https://github.com/johan/world.geo.json
Then you would probably want to use a more accurate detection method, for example leaflet-pip plugin or turf.js, which will actually check if your point is within arbitrarily shaped polygons, not just a rectangle.
See for instance Leaflet event: how to propagate to overlapping layers

Resources