-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Elevation measure widget #1881
Elevation measure widget #1881
Conversation
There is an issue with the Elevation widget : if you use it while zoomed out, the elevation is not red on the most detailed tile (since it is not necessarily loaded yet). The value will therefore differ on the same point, whether you use the widget while zoomed out or zoomed in at maximum. |
03be1e9
to
6d1178d
Compare
*/ | ||
pickCoordinates(mouse, target = new Coordinates(this.tileLayer.extent.crs)) { | ||
pickTerrainCoordinates(mouse, target = new Coordinates(this.referenceCrs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming this method introduces a breaking change. Could you still define pickCoordinates
with a deprecation warning and a calling to the new method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep and I will also add a breaking change in the commit message.
src/Core/View.js
Outdated
coordinates.crs = this.referenceCrs; | ||
coordinates.setFromVector3(positionVector); | ||
coordinates.as(target.crs, target); | ||
target.setFromVector3(positionVector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to leave the transformation here, since use should be able to call the method with any target
coordinate. We can't assume the CRS of target
. For example if I type :
const coordinates = new itowns.Coordinates('EPSG:4326');
view.pickTerrainCoordinates({ /* some mouse position */ }, coordinates);
it will return some coordinates with an EPSG:4326
CRS but whose x
, y
and z
values are intended as EPSG:4978
, so most probably not the coordinates under the mouse position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep you're right, I got mixed up :)
*/ | ||
pickCoordinates(mouse, target = new Coordinates(this.tileLayer.extent.crs)) { | ||
pickTerrainCoordinates(mouse, target = new Coordinates(this.referenceCrs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can indeed change the default target CRS with the view's reference CRS, as it seems more logical.
However we should keep these two following points in mind :
- this introduces a breaking change for some users (who for example feed the default output of this method to other processes without transforming it).
- In a
PlanarView
context, I believe thatview.referenceCrs
andview.tileLayer.extent.crs
are always the same. Having the default output CRS toview.tileLayer.extent.crs
allows to output coordinates in longitude, latitude and altitude, whose representation is more easy to understand than coordinates inEPSG:4978
.
Therefore, do you still think we should change it ? In any case, could you please add the previously missing documentation on the default output CRS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes because it is clearer for users since in my opinion users don't really know the crs of the extent of the tileLayer which is quite internal to itowns, they should expect to get coordinates in the view CRS which they actually know of. You're right that it is a breaking change, I will add one.
src/Core/Geographic/Coordinates.js
Outdated
* @param {number|Array<number>|Coordinates|THREE.Vector3} [v0=0] - | ||
* x or longitude value, or a more complex one: it can be an array of three | ||
* numbers, being x/lon, x/lat, z/alt, or it can be `THREE.Vector3`. It can | ||
* also simply be a Coordinates. | ||
* @param {number} [v1=0] - y or latitude value. | ||
* @param {number} [v2=0] - z or altitude value. | ||
*/ | ||
constructor(crs, v0 = 0, v1 = 0, v2 = 0) { | ||
constructor(crs = 'EPSG:4978', v0 = 0, v1 = 0, v2 = 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is a good addition, thanks !
On another hand, I don't think we should assume a default CRS for coordinates. No coordinates make sense without a CRS and in my opinion, user should always have to specify the CRS associated with the coordinates values he is dealing with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with you, I will remove the default CRS.
* Sets the Coordinate Reference System. | ||
* @param {String} crs Coordinate Reference System (e.g. 'EPSG:4978') | ||
*/ | ||
setCrs(crs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to add this check of parameter validity !
src/Core/Picking.js
Outdated
@@ -187,9 +188,16 @@ export default { | |||
// if baseId matches objId, the clicked point belongs to `o` | |||
for (let i = 0; i < candidates.length; i++) { | |||
if (candidates[i].objId == o.baseId) { | |||
// Compute distance to the camera | |||
const pointCoordinate = new Coordinates(view.referenceCrs, o.position.x, o.position.y, o.position.z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method for computing distance could cause issues : the position
property for threejs Object3D
is expressed in the object's parent coordinates system.
Here, the point could be centered within a Group
, and the Group
could be positioned at the correct world coordinates. the position
of the point would therefore be (0, 0, 0)
. Using world position for the point, as you did for the camera would prevent this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do you know of an usage of this picking method other than with PointCloudLayer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, I added the world transformation and updated a bit this part to fix a bug that I had not seen for point cloud picking.
d79c41b
to
86ac17f
Compare
@mgermerie I made the modifications you recommended, squashed and rebased. |
3cf694e
to
86ac17f
Compare
Some functional tests don't pass (timeout), while they pass locally. I tried to update a few things but it didn't change anything. Any ideas @mgermerie @gchoqueux ? |
86ac17f
to
8543d2a
Compare
BREAKING CHANGE: View.pickCoordinates has been renamed to View.pickTerrainCoordinates and returns the coordinates in the referenceCrs of the view instead of in the crs of the tiledLayer extent.
8543d2a
to
11cdf5f
Compare
11cdf5f
to
5595e57
Compare
5595e57
to
2dada14
Compare
I won't have time to finish this feature in the short term, closing for now. |
Description
Add a widget to measure elevation anywhere in the 3D scene. Also contains a few modifications of the API (
Picking
andView
).I will write tests and squash commits once we agree on the implementation :) (i.e. after a first review)
Note that I opened a PR on itowns2-sample-data for the assets related to this widget (sprite, logo and dataset for the example).
Motivation and Context
Implementation of the first tool described in #1868
Screenshots (if appropriate)
Mesure elevation on the terrain:
Mesure elevation on any 3D object:
![image](https://user-images.githubusercontent.com/16967916/183655203-47b88ad7-dee5-4e44-810b-905018dd6ebd.png)