MKMapView: any way to tell max/min visibleRect (zoom level)? - mkmapview

Is there a constant or method for determining the maximum and minimum zoom level or visible rect of MKMapView? I'm looking even for a proxy solution such as getting a "visibleRectForRect:" method perhaps. The goal is to know when a map is "fully zoomed in" (etc) and change the display settings of related UI accordingly.

Given that you can calculate the zoomLevel (http://stackoverflow.com/questions/4359424/check-whether-zoom-level-changed), we can reasonably-safely assume that the zoom level is bracketed between 1 and 21 (not future-proofed but certainly constant for some years now).
Thus, check the zoom level and use whatever threshold is "max" for your app. In my tests I could never get the map to go beyond 3-19, so I use that.

Related

Render objects based on zoom level in Azure indoor maps

Is there a way to show/hide objects on a map based on the zoom level in azure indoor maps module? Honestly, I'm not so sure if this feature even exist yet
Custom styling of indoor maps in Azure Maps is a planned feature.
Note that indoor maps leverage vector tiles for rendering and items that don't appear when zoomed out, are not loaded in the map, so you won't be able to show things that aren't there at this time. There will likely be some configuration for this in the future. Things that do appear today could potentially be hidden although in a bit of a hacky way since this custom styling of indoor maps isn't officially supported yet.
For example, using the building from the indoor maps tutorial, the following sets the zoom level range of the room number labels to 0 - 22.
map.map.setLayerZoomRange("indoor_global_unit_label", 0, 22)
The first value in that function is the id of the rendering layer which I retrieved by running the following code in the console, then moving the mouse over the item I wanted to get the id for:
map.events.add('mousemove', function (e) { console.log(e.shapes[0].layer.id ) })
The second and third parameter of the setLayerZoomRange method is the min and max zoom levels. When that line of code is ran, you will notice the labels appear when zoomed out much longer than usual, however, if you zoom out enough, they disappear since they become no longer available in the vector tiles.

MeshLab: fill cracks in mesh

I'm having trouble finding a way to solve this specific problem using MeshLab.
As you can see in the figure, the mesh with which I'm working presents some cracks in certain areas, and I would like to try to close them. The "close holes" option does not seem to work because, being technically cracks and not holes, it seems not to be able to weld them.
I managed to get a good result using the "Screened Poisson Surface Reconstruction" option, but using this operation (rebuilding the whole mesh topology), I would lose all the information about the mesh's UVs (and I can not afford to lose them).
I would need some advice to find the best method to weld these cracks, which does not change the vertices that are not along them, adding only the geometry needed to close the mesh (or, ideally, to make a weld using the existing edges along the edge).
Thanks in advance!
As answered by A.Comer in a comment to the main question, I was able to get the desired result simply by playing a bit with the parameters of the "close holes" tool.
Just for the sake of completeness, here is a copy of the comment:
The close holes option should be able to handle this. Did you try changing the max size for that filter to a much larger number? Do filters >> selection >> select border and put the number of selected faces as the max size into that filter – A.Comer

3D entity always visible, even when behind another entity

Is there an easy way to show 3D entity at all times, even when that entity is hidden behind another entity? For example, I want that lines are always shown event when they are behind mesh surface.
I use Qt3D framework.
Assuming that you are talking about the Qt3D framework I want to extend the answer of Rabbid76.
To disable depth-testing in the Qt3D framework, add a QRenderStateSet to the framegraph branch that renders things (the one that as a QViewPort for example) and add a QDepthTest to it. Then, set the depth function of the QDepthTest to always. This way, the depth test is always passed and entities in the back will also be drawn, depending on the drawing order. You can use QSortPolicy to adjust the drawing order to back-to-front.
But this won't work when the camera position changes and your entity that you always want to be drawn is in the front. I'd suggest you add another framegraph branch and use a QLayerFilter to only deactivate depth-testing for this one entity.
If your entity looks weird when deactivating depth-testing (likely for complex objects), you could replace the QDepthTest by a QClearBuffers and simply clear the depth buffer.
Have a look at my answer here, where I showed an example of a custom framegraph with depth test.
If the depth test is disabled, then the geometry (like a line) is always drawn on top of the previously drawn geometry. The depth test can be disabled by:
glDisable(GL_DEPTH_TEST)
See glEnable
As an alternative the depth test function, can be set to let a fragment always pass depth test. In Qt this can be done by the class QDepthTest, using the enumerator constant Qt3DRender::QDepthTest::Always.
In this case, you have to take care about the order in which the geometry is drawn.
You have to find a way, to render the polygons (opaque geometry) first, by using the depth test function Qt3DRender::QDepthTest::Less.
After that you have to render the lines on top, by using the depth test function Qt3DRender::QDepthTest::Always.

How can I got a point's GPS position when select it on the static map

Firstly,I use google static map API to get the image to display on html/wml.
And then, I want to get the point's GPS position where user pressed on the image.
Is there some way to get the GPS position if I got the co-ordinates on the image?
The short answer is probably not. You can't be sure exactly what the static map's dimensions are (the server might change the location slightly to fit things better, etc.). If you're just asking for a map by center and zoom then you stand a slightly better chance, but it will still be tricky.
If you're trying to add dynamic behaviour to a static map, have you considered instead the Maps JavaScript API? Finding the coordinates of where a user clicks is trivial there. (Also, you can disable the zooming, panning, controls, etc. if you want so that it still feels like it's static).

Confusion in two MFC GDI function

and good day to all of you. This is my first post in here. I was reading "Programming Windows with MFC - J Prosise (MS Press)"
In second chapter I came across 2 GDI functions that really confused me, I am quoting the text:
It's easy to get SetViewportOrg and SetWindowOrg confused, but the distinction between them is actually quite clear. Changing the viewport origin to (x,y) with SetViewportOrg tells Windows to map the logical point (0,0) to the device point (x,y). Changing the window origin to (x,y) with SetWindowOrg does essentially the reverse, telling Windows to map the logical point (x,y) to the device point (0,0)—the upper left corner of the display surface. In the MM_TEXT mapping mode, the only real difference between the two functions is the signs of x and y. In other mapping modes, there's more to it than that because SetViewportOrg deals in device coordinates and SetWindowOrg deals in logical coordinates
I am really confused with this, is is like if we change viewpoint origin to say (50,50) and then use dc.ellipse (0,0,50,50) it would start from the device point (50,50) as origin, but if we changed window origin to (50,50) would that means now logical point (50,50) would be mapped to (0,0) if that so, wouldn't the ellipse be out of client's area in the upper region? And what the mapping mode was MM_LOWENGLISH or something else? How would the situation change then? Please if anyone could shed some light on the matter I'd be really grateful
This is a rather complex question, mostly because you have two entirely separate sets of coordinates to deal with, and (just to keep things interesting) Windows uses roughly the reverse of the terminology the rest of the world uses.
The short answer is just don't use SetWindowOrg at all. I'm pretty sure I've never had a good use for it in real code.
SetViewportOrg is useful, and it's really simpler than the description makes it sound -- you're just picking out where you want your origin to be. For example, you might want your drawing to start from the bottom, left-hand corner of the window. You'd do that with something like:
CRect rect;
GetClientRect(&rect);
pDC->SetViewportOrg(0, rect.Height());
OTOH, if you want to be able to draw both negative and positive numbers, you might want x=0 to be at the left side of the window, but y=0 to be centered halfway between the top and bottom of the window. You'd do that something like:
// get rect as above.
pDC->SetViewportOrg(0, rect.Height()/2);
If you wanted the center of the window to be your (0,0), you'd use:
// again, get rect like above
pDC->SetViewportOrg(rect.Width()/2, rect.Height()/2);
Note that the primary use of either of these is with the mapping mode set to MM_ISOTROPIC or MM_ANISOTROPIC -- these are where you get to set the coordinates completely on your own. With the other modes [MM_TEXT or MM_(LO|HI)(ENGLISH|METRIC)], it sets up an origin for you automatically.

Resources