I am attempting to place a hexagon (centred over co-ordinates) which I can interact with, hover/onclick. The method I am using is to LoadImage(..._Hexagon.png) and then addLayer. Eventually the idea is to have many hexagons over specific areas.
I have obtained the desired interaction with the shape, but I would like this layer to be invariant under zoom (ie I have the hexagons cover an area of x square km at all times regardless of zoom). Is there an efficient way to do this? Will another method be better? etc
Thank you in advance for any and all advice!
If you really want to scale an icon such that it gets bigger as you zoom in, you can use an exponential scale:
"icon-scale": ["*", ["interpolate", ["exponential", 2], ["zoom"]], SCALE]
where SCALE is some constant you pick.
It probably makes more sense to actually generate hexagonal polygon data (eg, using Turf), and displaying that though.
Related
Can you change the size of pixels in Density Map?
I suspect that the size of density map pixels is based on agent/pedestrian size. Can it be modified, so that pixels are smaller and leave more precise trace?
Currently, my density map leaves huge pixels that are very difficult to use as reliable information.
EDIT: Screenshot below,
Thanks,
Peter
I am pretty sure it's not possible, the density map has a resolution of 1 meter (whatever the equivalent to 1 meter is by your scale object) and there's no way to change it (as far as I know)
But, what you have to make up for this, is the canvas object that you can find in the presentation palette. With the canvas object you can define your own resolution but you also have to code your own density map using your own personalized rules. Check the help documentation to understand how to use this and check the wondering elephants model to understand how to make changes dynamically.
I have an image (see attached) and I am trying to calculate the variance of the image inside the region of interest (dark region) using the stdfilt function.Image here.
The dark side is what I need to work on. When I use stdfilt on this image, it shows me the boundaries of the dark and bright.
My idea is that we can threshold the image to show only the dark side and tell Matlab to work only with this region of interest. So far, did not find a proper way of doing this.
The area is not a perfect polygon, which would make things way easier. At that point, I'm not sure what to do, so any suggestions are welcome.
Cheers
If the spatial location of the pixels is not relevant, you could just do:
datatoprocess=I(I<threshold);
Being threshold a value that separates the white from black. [graythresh][1] is a fantastic function for that. datatoprocess will be a 1xN array with the pixel values.
If, instead, the spatial location of the pixels is relevant, then you need to modify your functions to not work on specific pixels. The best approach for this is generally setting NaN values in pixels you dont want to take into account.
Itoprocess=I;
Itoprocess(I>threshold)=NaN;
Without more information on what exactly are you doing with the image, this is the best anyone can get to.
Is it possible to have irregularly shaped images positioned adjacent to each other, where each individual image is clickable within its own boundaries?
For example, if I had a map of the US and I want to click each state and have a separate segue for each:
(https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Map_of_USA_with_state_names.svg/2000px-Map_of_USA_with_state_names.svg.png)
I appreciate any tips/pointers in the right direction. Thanks!
Whether the map is really a bunch of irregularly shaped images, or just one image, is immaterial. (The latter will be easier.) You can just define a separate UIBezierPath objects that outline each of the states, and then you can use the UIBezierPath method containsPoint to determine whether some tap point is contained within the respective state.
Frankly, you might consider how much accuracy you really need. For example, if looking at map of US from continental scale, you really don't need extremely accurate bezier paths. Often a simple irregular polygon shape can approximate the boundaries and is more than sufficient for hit tests.
In fact, you sometimes deliberately use a much bigger bezier path. For example, you might draw a single path that goes around all of the Hawaiian islands, with some leeway, so that you don't have to tap right on the actual island, but just somewhere close. Or, for Rhode Island, you might allow a tap on the text "Rhode Island", as well as the state itself.
Seems like a simple question, but I have been tearing my hair out for hours now.
I have a series of files ie.
kml_image_L1_0_0.jpg
kml_image_L2_0_0.jpg
kml_image_L2_0_1.jpg
kml_image_L2_1_0.jpg
kml_image_L2_1_1.jpg
etc. However just plotting them on the leaflet map surface understandibly puts the images at 0,0 on the earths surface, and the 0 zoom level inferred by the files should really be about 15 or so.
So I want to specify the latitude and longitude where the images should originate , and what zoom level they should start at. I have tried bounds (which doesn't display anything) and I have tried playing with offsetting the zoom level.
I need this because a user needs to click on an offline map to specify where they are and I need the GPS coordinates.
I also have a KML file but it seems to be of more help for plotting vector data on the map.
Any help is much appreciated, cheers.
If I understand correctly, the "kml_image_Lz_x_y.jpg" images that you have are actually tiles, with zoom, horizontal and vertical indices in their file name?
And your issue is that they use (z,x,y) numbers as if they started from the top-most level (zoom 0, single tile for entire world), but in fact they are just a small portion of the pyramid of tiles?
And you cannot use them as is because you still want to get actual geographic coordinates (latitude, longitude), which would be totally wrong if you used the tiles as if they were showing the entire world?
In that case, you have several options as workarounds:
The most simple and reliable would probably be to simply write a small script to rename all your tiles to their true (z,x,y) numbers.
Another option would be to modify the (z,x,y) numbers before they are written in the tile src attribute, and apply the appropriate offset (constant for z, scaled by z for x and y). That should probably happen in L.TileLayer.getTileUrl() method.
Good luck! :-)
Maybe I'm asking this too soon in my research, but I'd better know if this is possible sooner than later.
Imagine I have the following square printed on a paper on top of a table:
The table is brown, so it does not match with any of the colors in the square. Is there a way for me, from a common iPhone camera (non-stereo view), to figure out the distance and angle from which Im looking at the square in the table?
In the end what I'm looking for is being able to draw a 3D square on top of this one using the camera image, but I'm not sure if I am going to be able to figure out the distance and position of the object in space using only a 2D image. Any hints are well appreciated.
Short answer: http://weblog.bocoup.com/javascript-augmented-reality
Big answer:
First posterize, Then vectorize, With the vectors in your power you may need to do some math tricks to define, based on the vectors position, the perspective and then the camera position.
Maybe this help:
www.pixastic.com/lib/docs/actions/posterize/
github.com/selead/cl-vectorizer
vectormagic.com/home
autotrace.sourceforge.net
www.scipy.org/PyLab
raphaeljs.com/
technabob.com/blog/2007/12/29/video-games-get-vectorized/
superuser.com/questions/88415/is-there-an-open-source-alternative-to-vector-magic
Oughta be possible. Scan the image for the red/blue/yellow pattern, then do edge detection to figure out how warped the squares are (they'll be parallelograms in anything but straight-on view). Distance would depend on the camera's zoom setting and scan resolution. But basically you'd count how many pixels are visible in each of the squares, run that past the camera's specs and you should be able to determine a rough distance.