@@ -66,19 +66,20 @@ var DragNDrop = (function _() {
66
66
data = new window . DOMParser ( ) . parseFromString ( data , 'text/xml' ) ;
67
67
}
68
68
69
+ var crs = extension . mode == _GEOMETRY ? _view . referenceCrs : _view . tileLayer . extent . crs ;
70
+
69
71
extension . parser ( data , {
70
72
in : {
71
73
crs : 'EPSG:4326' ,
72
74
} ,
73
75
out : {
74
- crs : ( extension . mode == _GEOMETRY ? _view . referenceCrs : _view . tileLayer . extent . crs ) ,
76
+ crs : crs ,
75
77
buildExtent : true ,
76
78
mergeFeatures : true ,
77
79
structure : ( extension . mode == _GEOMETRY ? '3d' : '2d' ) ,
80
+ forcedExtentCrs : crs != 'EPSG:4978' ? crs : 'EPSG:4326' ,
78
81
} ,
79
82
} ) . then ( function _ ( features ) {
80
- var dimensions = features . extent . dimensions ( ) ;
81
-
82
83
var source = new itowns . FileSource ( {
83
84
features : features ,
84
85
crs : 'EPSG:4326' ,
@@ -102,29 +103,32 @@ var DragNDrop = (function _() {
102
103
source : source ,
103
104
} ) ;
104
105
} else if ( extension . mode == _GEOMETRY ) {
105
- layer = new itowns . GeometryLayer ( file . name , new itowns . THREE . Group ( ) , {
106
- update : itowns . FeatureProcessing . update ,
107
- convert : itowns . Feature2Mesh . convert ( {
108
- color : new itowns . THREE . Color ( randomColor ) ,
109
- // Set the extrusion according to the size of
110
- // the extent containing the data; this quick
111
- // formula is totally arbitrary.
112
- extrude : dimensions . x * dimensions . y / 1e6 ,
113
- } ) ,
114
- source : source ,
115
- opacity : 0.7 ,
116
- } ) ;
106
+ layer = new itowns . FeatureGeometryLayer (
107
+ file . name ,
108
+ {
109
+ style : new itowns . Style ( {
110
+ fill : {
111
+ color : 'red' ,
112
+ extrusion_height : 200 ,
113
+ } ,
114
+ } ) ,
115
+ source : source ,
116
+ opacity : 0.7 ,
117
+ } ) ;
117
118
} else {
118
119
throw new Error ( 'Mode of file not supported, please add it using DragNDrop.register' ) ;
119
120
}
120
121
121
122
_view . addLayer ( layer ) ;
122
123
123
- // Move the camera to the first vertex
124
- itowns . CameraUtils . animateCameraToLookAtTarget ( _view , _view . camera . camera3D , {
125
- coord : new itowns . Coordinates ( features . crs , features . features [ 0 ] . vertices ) ,
126
- range : dimensions . x * dimensions . y * 1e6 ,
127
- } ) ;
124
+ var extent = features . extent . clone ( ) ;
125
+ // Transform local extent to data.crs projection.
126
+ if ( extent . crs == features . crs ) {
127
+ extent . applyMatrix4 ( features . matrixWorld ) ;
128
+ }
129
+
130
+ // Move the camera
131
+ itowns . CameraUtils . transformCameraToLookAtTarget ( _view , _view . camera . camera3D , extent ) ;
128
132
} ) ;
129
133
} ;
130
134
0 commit comments