Graph does not render properly due to vertices overlap - mxgraph

Graph is not rendering properly because two vertex has the same co-ordinates hence the length of the edge between this two vertex is zero.Since edge's length is zero the x&y co-ordinates are set as NaN in mxParallelEdgeLayout.prototype.layout function.
How can I ensure vertices not to overlap and stay at least a certain distance from one another.Our application uses mxFastOrganicLayout layout and mxgraph version is 1.8.0.5.

Related

How do I estimate 3D position of an object in video?

I want to find a 3D position coordinates (X, Y, Z) of a moving object.
I have a training set of pictures (frames from video) with a known ground truth XYZ position of an object.
The goal is to detect the object in the the input video and draw overlay with bounding edges and XYZ coordinates in real time 30fps.
Video stream is captured from a single fixed camera. Camera axis are not aligned with a world coordinate system (it's tilted and rotated). There will be maximum one object in a frame.
Is there existing models that can do it? Where can i start from?

Static image positioned far north gets stretched

In our application we have a backend that does some raster processing on a region of a map and sends back an image to the OL-based frontend which inserts the image at the specified extent.
The polygon to process is sent as GeoJSON-coords (EPSG:4326) to the backend which then transforms the polygon to a rectangular projection (EPSG:3035 in this case), does the processing and sends the heatmapped results back to the frontend as a PNG-encoded image, reprojected server-side to EPSG:3857 (to match the projection of our OSM-based background map). The image is then inserted in an ImageLayer using an ImageStatic object, whose extent is computed by the backend (the EPSG:3035-transformed bounding box of the image transformed to EPSG:3857).
This works fine, except for polygons in the far north of Scandinavia. For instance, the image whose extent in EPSG:3857 is [1684632.9133543067,9544855.787615912,2902401.684702249,10831736.048522325] is visualized the following way when added to the map:
The desirable result is for the image to follow the south-eastern boundaries of the shadowed polygon. Instead it is skewed and stretched out to the north-east.
I would be very grateful for any ideas and pointers as to why this is not working as expected.
I solved this by cropping the image to be reprojected as much as possible. The resulting envelope is then much smaller which did away with the distortions. Thanks for hint #Ian!

Forge Viewer - Markups - can we get xy coordinates of the current selection?

I am using markup extension to draw on my viewer, after drawing, on selection of markup event, can I get its center coordinates of current selection or any coordinates inside of it?
if not, at least can I get dbId behind current selection?
Thanks in advance
Yelp~ it's the case, and see also:
// Get the markup's position in browser pixel space. the (0,0) is top left
Markup#getClientPosition()
// Get the markup's bounding rect in browser pixel space.
Markup#getClientSize()
// get the markup's bounding rect in browser pixel space, including the stroke width
Markup#getBoundingRect()
BTW, to obtain dbId within the markup boundary, you can do this:
Get markup's BoundingRect in browser's pixel space
Convert coordinates of the rect's vertices into viewer's 3d space via
Viewer3D#clientToWorld
Do bounding box collision to find out intersected mesh for the dbId, see here for the example:
https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-simpler-extension

Function for densest sphere packing inside a sphere

I'm trying to write a function for the densest packing of identical spheres inside a spherical boundary.
I'm thinking it will be something like spherepack(c,r,n), where:
c - centre of the boundary sphere (x,y,z coordinates)
r - radius of the boundary sphere
n - number of identical spheres to be packed inside the boundary
I want the outputs to be the x,y,z coordinates of the centre of each packed sphere. Does anyone know how this could be done?
How about what you might call the 'brute force' method. ie Model what would happen if you had a pile of n unit sized spheres and just tried packing them together in every possible close-packed configuration, and then measured the smallest containing sphere for the pack. I can imagine an algorythm for that, but it is not very programatically efficient, or mathmatically beautiful. Would it have to run fast, or just get the right answer?
Unfortunately, the assumption that close packing is densest is not correct :(

Calculating bounding grid coordinates to a user click on google maps/google earth

I have a requirement to calculate the centroid or geodesic midpoint of
when a user clicks in between the lat/long grid crossing.
The crossing forms a square in most parts of GE and sometimes
elongated rectangles. This is due to the shape of the earth of course.
I'm looking for a valid mathematical formula that would allow a user
to click anywhere in between this grid and then an accurate function
(in Javascript or server side code) that would take an assumed grid
resolution (say 1km intervals for this discussion) and the input
coordinates that should return a centroid coordinate within that
graticule grid.
To clarify please take a look at the attached image to my google group post:
http://google-earth-api.googlegroups.com/web/Picture+5.png?gda=h5oFPz8AAAD315KpovipQeBwdfGpmW3ZhBc9PTADwYa-n193hZ6AItFmHuno63c7phcEXYVuRA6ccyFKn-rNKC-d1pM_IdV0&gsc=sz6bbAsAAABBKF7YXWYyc4GmXg-QruHj
What I need to be able to do is if a user clicks anywhere in this grid
square, I need to find the centroid or center point of that grid
intersection/square or at least the bounding grid coordinates (that make the square).
If we assume that the grid is UTM standard and has a max resolution of
1km (or make this a parameter), I need to detect the four other points
nearby and then calculating the centroid is not as difficult.
I welcome any feedback you all may have and appreciate it.
I don't have a simple way of letting a user click anywhere on the grid and finding the grid bounding coordinates (making a square of 4 coordinates) or the centroid / midpoint of the graticule grid square necessary.
One thought is to use assumptions as much as possible using a reference such as UTM coordinate reference.
If I assume that the grid is X degrees wide, can we have a pure javascript function take any input coordinate and return for me the bounding graticule coordinates in Decimal Degrees?
Another thought I had was to create the grid in a geo-spatial layer to take any input coordinate and return the nearest centroid of the graticule?
Does this make sense?
Thanks!
Omar
this seems to be a rounding problem
1) your users click anywhere on the map
2) you want to trap the click to read out the actualLat/actualLon values
3) and round it down to the nearest discrete grid values minLat/minLon
4) then you want to calculate and return in some way the midpoint of the grid as
midLat = minLat + deltaGridLat/2;
midLon = minLon + deltaGridLon/2;
ad 2) look up the .js file in my Maidenhead locator viewer - you can surely reuse code for initializing the GE event handler and the handler for a mouse click (note I am trapping a RIGHT click)
The event handler essentially takes the user chosen location, passes it to function CoordToLoc() where the coordinates are converted to a Maidenhead locator string, which then is displayed in field inpLocator on the web page.
ad 3) this depends on your grid - if it is bound to discrete Lat/Lon values (as in my case) it's as simple as rounding. If the grid points are defined as distance offsets in km from a reference point, the simple approach would be to divide your argument by the unity length and disregard the decimal places
Hope this helps
Good luck
MikeD