@@ -66,19 +66,20 @@ var DragNDrop = (function _() {
6666 data = new window . DOMParser ( ) . parseFromString ( data , 'text/xml' ) ;
6767 }
6868
69+ var crs = extension . mode == _GEOMETRY ? _view . referenceCrs : _view . tileLayer . extent . crs ;
70+
6971 extension . parser ( data , {
7072 in : {
7173 crs : 'EPSG:4326' ,
7274 } ,
7375 out : {
74- crs : ( extension . mode == _GEOMETRY ? _view . referenceCrs : _view . tileLayer . extent . crs ) ,
76+ crs : crs ,
7577 buildExtent : true ,
7678 mergeFeatures : true ,
7779 structure : ( extension . mode == _GEOMETRY ? '3d' : '2d' ) ,
80+ forcedExtentCrs : crs != 'EPSG:4978' ? crs : 'EPSG:4326' ,
7881 } ,
7982 } ) . then ( function _ ( features ) {
80- var dimensions = features . extent . dimensions ( ) ;
81-
8283 var source = new itowns . FileSource ( {
8384 features : features ,
8485 crs : 'EPSG:4326' ,
@@ -102,29 +103,32 @@ var DragNDrop = (function _() {
102103 source : source ,
103104 } ) ;
104105 } 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+ } ) ;
117118 } else {
118119 throw new Error ( 'Mode of file not supported, please add it using DragNDrop.register' ) ;
119120 }
120121
121122 _view . addLayer ( layer ) ;
122123
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 ) ;
128132 } ) ;
129133 } ;
130134
0 commit comments