How to get coordinates when I hit the object in X3D? - x3d

I found that when I hit the object with mouse,I will receive coordinates in the console like this:
"
INFO: Ray hit at position -0.8909352080500961 0.004276552687857628 -1.0112924948899256
INFO: Hit "Shape/ null"
INFO: Ray hit at position -0.8915609839018154 0.0019779635524881855 -1.0258166943957363
INFO: Hit "Shape/ null"
INFO: Ray hit at position -0.8910244952200963 -0.014531608631342386 -0.9694042420800579
INFO: Hit "Shape/ null"
"
But I want to pass these coordinates as parameters of some functions,what should I do?

In X3DOM:
Here is an example:
http://x3dom.org/x3dom/example/x3dom_onClickEvent.xhtml
The middle two objects access coordinates in JavaScript.
The coordinates will be in the event.hitPnt argument of the onclick callback.

Related

Selenium chrome error using wild cards in SwitchTo().Frame("xxx*yy")

Hi I am challenged by this error using Wildcard(*) in a string to locate a frame !
When i write the complete name of the iFrame in the statement, it has no issues finding the Frame .
Your thoughts are appreciated!
driver.SwitchTo().Frame("*_ifr")
OpenQA.Selenium.NoSuchFrameException: 'No frame element found with name or id *_ifr'
When I enter the entire frames name like below, it works just fine
driver.SwitchTo().Frame("txt-client-instructions_ifr")
I expect the wildcard will find the following iframes
1st txt-client-instructions_ifr
2nd 107314_100323_ifr
3rd 107341_100324_ifr
4th 100321_macrotext_ifr
SwitchTo().Frame() is the method to give you access to switch frames and windows. The argument type is of String. As an example:
driver.SwitchTo().Frame("FrameName");
String doesn't support wildcards where as By.CssSelector or By.XPath supports wildcards.
Hence,
driver.SwitchTo().Frame("txt-client-instructions_ifr")
is successful, where as:
driver.SwitchTo().Frame("*_ifr")
raises OpenQA.Selenium.NoSuchFrameException.

How to get the latitude and longitude in Open layers

I am drawing one line from Location A to Location B using React.JS with Open Layers. I wish to get the Latitude and Longitude of the Location A and Location B.
I have added one listener after draw completion. But it is giving the co-ordinates as below . How can I get the latitude and longitude?
Listener:
draw.on('drawend',function(e){
console.log("Co Ordinates :",e.feature.getGeometry())
//console.log("Co Ordinates :",e.feature.getGeometry().getExtent())
});
Console :
Extent and flat coordinates values are printed in console as below
extent_:(4) [8732987.679175382, 1920132.5190330548, 8735555.9637923, 1920254.817578509]
flatCoordinates:(4) [8732987.679175382, 1920132.5190330548, 8735555.9637923, 1920254.817578509]
If you are just looking for a way to convert the coordinates you can use ol.proj.transform(coordinate, source, destination)
Using this
ol.proj.transform([8732987.679175382, 1920132.5190330548], 'EPSG:3857', 'EPSG:4326')
Will give this as output
[78.44976308230713, 16.99405070970775]
Also note that you can use getFirstCoordinate and getLastCoordinate methods on the line feature to get the first and last coordinates.
OpenLayer is working on different location formats like EPSG: 3857, EPSG: 4285 etc.
There are some Transform/Projection api enter link description here
Use this api's and transfer your locations to your desired formats

Latitude out of bounds

I get following exception when using Entity Framework to get data from bounds from a google map:
FormatException: 24201: Latitude values must be between -90 and 90 degrees.
POLYGON((81.9882716924738 140.187434563007,21.5587046599696 140.187434563007,21.5587046599696 -40.1641279369925,81.9882716924738 -40.1641279369925,81.9882716924738 140.187434563007))
I can see other have same problem, but havent found anything that solves this. I would expect that first coordinate for point is the latitude and second for longitude? And none is above 90 so why do I get this error? I tried swapping lat and lng but with same problem.
This is the failing line:
var poly = FindByBoundingBox(northEastLat, northEastLng, southWestLat, southWestLng);
DbGeography polygon = DbGeography.FromText(poly, 4326);
var parksWithinPolygon = dbCtx.SiteList.Where(p =>
p.PolygonCenter.Intersects(polygon)).Select(p=>p.SiteName).ToList();
As Damien states first problem is that Sql server expects longitude first and then lattitude. This throws another error, redirecting to another problem:
"This operation cannot be completed because the instance is not valid".
My best bet is it's the they way/order I build the polygon. Has anyone succeeded in mapping google bounds to a polygon in SQL server? In short I am trying to get any data (data has a point column) within the google map bounds.
The function to calculate polygon is listed below:
public string FindByBoundingBox(double northEastLat, double northEastLng, double southWestLat, double southWestLng)
{ //Create poylgon of bounding box
System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
var bboxWKT = string.Format("POLYGON(({1} {0},{1} {2},{3} {2},{3} {0},{1} {0}))", northEastLat, northEastLng, southWestLat, southWestLng);
return bboxWKT;
}
OK i figured it out. As Damien stated the order of coordinates is oppesite of google. In SQL long needs to be first. Next thing is what is the "left hand rule". You need to create your polygon starting from lower left corner and then counter clock wise.

return of getText() cannot be compared to a string

I am using a following code to compare 2 strings in one of protractor/jasmine test cases.
emailnotsentmessage.getText().then(function(text) {
expect(text).toBe('has not received notification about recent changes to the meeting.');
});
where emailnotsentmessage contains following text
[ 'has not received notification about recent changes to the meeting.' ]
for some reason , the string comparison fails . those two strings contains absolute same content. i checked it several times . am i missing something here ?. the emailnotsentmessage is a content of a <span> .
error trace
1) Get to the existing meeting by navigating to the edit meeting page should display the same value which was entered du
ring create meeting when go into edit meeting
Message:
Expected [ 'has not received notification about recent changes to the meeting.' ] to equal 'has not received notific
ation about recent changes to the meeting.'.
Stack:
Error: Failed expectation
Looks like your emailnotsentmessage is array and not a string. What if you try expect(text).toBe(['has not received notification about recent changes to the meeting.']); or maybe emailnotsentmessage[0]
found a fix and the reason behind this issue
i was earlier using var emailnotsentmessage = element.all(by.css('css path')); to get the element which caused the problem . It returns the string in an array format . instead i used the element(by.css('css path')); and it returns the expected string value .

How can I perform a Hit Test on one specifc 3d object in WPF?

I have a SphereMesh (inherits from MeshGeneratorBase as part of the Petzold.Media3D.dll) in my WPF 3D Scene. I also have thousands of ScreenSpaceLines3D objects on that sphere. I want to ignore everything in my scene except the SphereMesh and find out the X-Y-Z coordinate of where my mouse ray intersects with the sphere only. Even if there is another object X between the sphere and the mouse, I still want to know where the mouse would hit the sphere, as if object X didn't exist.
I've tried the below code using HitTest, but as I add thousands/millions of other objects in my scene/world, it becomes extremely slow. And the object obstruction issue is another problem I can't resolve.
What do you recommend?
Current code:
Point mousePos = new Point(x, y);
PointHitTestParameters hitParams = new PointHitTestParameters(mousePos);
VisualTreeHelper.HitTest(
viewPort,null,
delegate(HitTestResult hr)
{
RayMeshGeometry3DHitTestResult rayHit = hr as RayMeshGeometry3DHitTestResult;
if(rayHit != null)
{
// Mouse hits something
Console.WriteLine("Point: " + rayHit.PointHit);
}
return HitTestResultBehavior.Continue;
}, hitParams);
Any help?
Thanks.

Resources