Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoder flies to rectangle crossing IDL #3087

Merged
merged 1 commit into from
Oct 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,10 @@ define([
//>>includeEnd('debug');

ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
if (this._mode !== SceneMode.SCENE3D && rectangle.west > rectangle.east) {
rectangle = Rectangle.MAX_VALUE;
}

if (this._mode === SceneMode.SCENE3D) {
rectangleCameraPosition3D(this, rectangle, ellipsoid, this.position);
} else if (this._mode === SceneMode.COLUMBUS_VIEW) {
Expand Down
27 changes: 15 additions & 12 deletions Source/Widgets/Geocoder/GeocoderViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define([
'../../Core/jsonp',
'../../Core/Matrix4',
'../../Core/Rectangle',
'../../Scene/SceneMode',
'../../ThirdParty/knockout',
'../../ThirdParty/when',
'../createCommand'
Expand All @@ -24,6 +25,7 @@ define([
jsonp,
Matrix4,
Rectangle,
SceneMode,
knockout,
when,
createCommand) {
Expand Down Expand Up @@ -201,13 +203,22 @@ define([
}
});

function updateCamera(viewModel, position) {
var scratchPosition = new Cartesian3();
function updateCamera(viewModel, destination) {
var scene = viewModel._scene;
if (viewModel._flightDuration === 0) {
viewModel._scene.camera.setView({position: position});
var isRectangle = defined(destination.west);
if (isRectangle) {
if (scene.scene.mode !== SceneMode.SCENE3D && destination.west > destination.east) {
destination = Rectangle.MAX_VALUE;
}
destination = scene.camera.getRectangleCameraCoordinates(destination, scratchPosition);
}
viewModel._scene.camera.setView({position: destination});
viewModel._complete.raiseEvent();
} else {
viewModel._scene.camera.flyTo({
destination : position,
destination : destination,
complete: function() {
viewModel._complete.raiseEvent();
},
Expand Down Expand Up @@ -275,16 +286,8 @@ define([
var west = bbox[1];
var north = bbox[2];
var east = bbox[3];
var rectangle = Rectangle.fromDegrees(west, south, east, north);

var camera = viewModel._scene.camera;
var position = camera.getRectangleCameraCoordinates(rectangle);
if (!defined(position)) {
// This can happen during a scene mode transition.
return;
}

updateCamera(viewModel, position);
updateCamera(viewModel, Rectangle.fromDegrees(west, south, east, north));
}, function() {
if (geocodeInProgress.cancel) {
return;
Expand Down