only allow snap starting or ending points of lineString in Openlayers3 - openlayers-3

I am working a Web application with Openlayers3, there is a question about snapping. I only want to snap the starting point or ending point (not snap between 2 points) of lineString, and only allow to modify on nodes (disable creating node between 2 nodes). Glad to see any help about it.

create a point vector layer and populate it with start end points of the lines you want to be used for snapping.
Then initialise your snapping control and pass the source of this vector layer to snap interaction.

Related

Konva object snapping with transformer jitters

I'm trying to make an editor using Konva.js.
In the editor I show a smaller draw area which becomes the final image. For this I'm using a group with a clipFunc. This gives a better UX since the transform controls of the transformer can be used "outside" of the canvas (visible part for the user) and allow the user to zoom and drag the draw area around (imagine a frame in Figma).
I want to implement object snapping based on this: https://konvajs.org/docs/sandbox/Objects_Snapping.html. (just edges and center for now) However I want it to be able to work when having multiple elements selected in my Transformer.
The strategy I'm using is basically calculating the snapping based on the .back element created by the transformer. When I know how much to snap I apply it to every node within the transformer.
However when doing it, the items starts jittering when moving the cursor close to the snapping lines.
My previous implementation was having the draw area fill the entire Stage, which I did manage to get working with the same strategy. (no jitter)
I don't really know what the issue is and I hope some of you guys can point me in the right direction.
I created a codepen to illustrate my issue: https://codesandbox.io/s/konva-transformer-snapping-1vwjc2?file=/src/index.ts

ARKit + Core location - points are not fixed on the same places

I'm working on developing iOS AR application using ARKit + Core location. And the points which are displayed on the map using coordinates move from place to place when I go. But I need they are displayed on the same place.
Here you can see the example of what I mean:
https://drive.google.com/file/d/1DQkTJFc9aChtGrgPJSziZVMgJYXyH9Da/view?usp=sharing
Could you help to handle with this issue? How can I have fixed places for points using coordinates? Any ideas?
Thanks.
Looks like you attach objects to planes. However, when you move the ARKit extends the existing planes. As a result if you put points, for example, at the center of the plane, then the center is always updated. You need to recalculate the coordinates of the point and place objects correctly.
The alternative is not to add objects to planes (or in relation to them). If you need to "put" object on a plane, then the best way is to wait, until the plane will be directed enough (it will not change his direction significantly if you will move), then select a point on the plane where you want to put your object, then convert this point coordinate to global coordinates (as a result if plane will change his size the coordinate you have will not be changed at all), and finally put object in root (or another object that it's not related to the plane).

Get real coordinates of Point (or any other constructed object)

In GeoGebra, you can easily construct scenes with the GUI and the tools available in the Graphics view. I now have two functions and created some objects around them using that tools (Their intersection point, a circle tangent to both etc.). The whole depends on 5 parameters I defined as sliders for testing.
Now I want to know the coordinates of the point. It is defined as Intersect[l, h] which doesn't help me. I can access its coordinates too (0.8, 3.98) but I want to know how to calculate them depending on the parameters. (I'd expect it to be something like (3a, 7+b-2a)). I know GeoGebra can do this because it must have done it internally to be able to draw the whole image. But I don't know how to access this information.
If you want to get the current position of a Point P you can use the x and y commands. These will update whenever the position of P changes so that you don't have to recalculate where the point should be by hand.

What is snap interaction in Openlayer3?

technically what happens with snap interaction in openlayers.
referance http://openlayers.org/en/v3.8.2/examples/snap.html
From the API documentation of the Snap interaction:
Handles snapping of vector features while modifying or drawing them.
The features can come from a ol.source.Vector or ol.Collection Any
interaction object that allows the user to interact with the features
using the mouse can benefit from the snapping, as long as it is added
before.
The snap interaction modifies map browser event coordinate and pixel
properties to force the snap to occur to any interaction that them.
See: http://openlayers.org/en/v3.8.2/examples/snap.html
In other words, the Snap interaction listens to the browser events that occur on the map and modifies its inner coordinates to "snap" to the closest vertex or segment of a nearby feature. Any other interaction that are added to the map before a snap interaction will use the updated coordinates, because the "top-most, i.e. last" interactions are handled first.
In openlayer, snap interaction will help you move to vertex/edge of polygon more precise. When you mouse near the vertex/edge, snap will move your pointer stand on the vertex/edge. Without snap, you must do it by yourself
You can try here . Comment last line map.addInteraction(snap);, then draw polygon, and move pointer around it, you will see the difference
Snap also is popular term in map system. You can take a look more at here

Can parent node positions be moved via child node positions in SceneKit (swift)

I am currently trying to get to grips with SceneKit using Apple's Swift language, it seems nice and straight forward but I was wondering if anyone has been able to move an entire nodes position by changing a child nodes position?
I mean, naturally moving the parent would move the child but I am using snap points in models to position objects correctly and the snap points are children of the overall object node.
For example, I want to snap object A's child node to object B's child node (overall moving object B to the correct offset). I do currently have this implemented, the positions are working correctly, all the correct values are in place however the parent model isn't moving on demand. Is this actually possible or am I following a wrong path?
Thanks in advance :)
that's definitely possible, but you will have to write your own utils.
If T is the transform (translation) that allows you to position your child nodes correctly, you can use [nodeBChildNode convertTransform:T toNode:nodeB] to convert that transform and then apply it on nodeB.

Resources