變壓器位置with範圍展示
yuanhung
2016-08-16 e3d6da37ac178414e3b607cd39475963acbe6766
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
/* Ximple */
 
//OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:3826", OpenLayers.Layer.SphericalMercator.projectForward);
//OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3826", OpenLayers.Layer.SphericalMercator.projectForward);
OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:3826", OpenLayers.Projection.nullTransform);
 
 
 
//GJSONPARSER
function GJSonParser(options){
    var parserRule={};
    var applySetting=function(opt){
        parserRule.sourcePrj=opt.sourcePrj || 'EPSG:4326';
        parserRule.targetPrj=opt.targetPrj || 'EPSG:4326';
        parserRule.root0=opt.root0||'';
        parserRule.rootGeom=opt.rootGeom||'';
        parserRule.rootAttrib=opt.rootAttrib||'';
 
        parserRule.attributeMapping=opt.attributeMapping||[];
        parserRule.colX=opt.colX||'X';
        parserRule.colY=opt.colY||'Y';
    }
 
    applySetting(options||{});
 
    this.getparserRule=function(){ return parserRule;}
    this.makeMapCol=function(src,tar){
        return {"src":src,"tar":tar};
    }
    var builder= function()
    {
        var newOptions={};
        this.src=function(sourcePrj){newOptions.sourcePrj=sourcePrj;return this;};
        this.tar=function(targetPrj){newOptions.targetPrj=targetPrj;return this;};
        this.root0=function(root0){newOptions.root0=root0;return this;};
        this.rootGeom=function(rootGeom){newOptions.rootGeom=rootGeom;return this;};
        this.rootAttrib=function(rootAttrib){newOptions.rootAttrib=rootAttrib;return this;};
        this.colX=function(colX){newOptions.colX=colX;return this;};
        this.colY=function(colY){newOptions.colY=colY;return this;};
        this.addCol=function(src,tar){
            if(newOptions.attributeMapping==null)newOptions.attributeMapping=[];
            newOptions.attributeMapping.push( {"src":src,"tar":tar});
            return this;
        };
        this.build=function()
        {
            return newOptions;
        }
    }
    this.optionsBuilder=function(){
        return new builder();
    }
 
    this.parser=function(gJson,opt){
 
        dbgOption=opt;
        if(opt==null) opt={};
        var results=[];// {"type":"FeatureCollection",features:[]};
        var parserList=opt.attributeMapping||parserRule.attributeMapping;
 
        var aResult;
        var dx;
        var dy;
        var tempRootstr=(opt.root0||parserRule.root0);
        if (tempRootstr.length>0)tempRootstr='.'+tempRootstr;
        var Items= eval("gJson"+ tempRootstr); //(opt.root0||parserRule.root0));     //gJson[opt.root0||parserRule.root0];  //maybe deeper then1
        //rootGeom
        var tempGeomstr=(opt.rootGeom||parserRule.rootGeom);
        if (tempGeomstr.length>0)tempGeomstr='.'+tempGeomstr;
 
        var tempAttrstr=(opt.rootAttrib||parserRule.rootAttrib);
        if (tempAttrstr.length>0)tempAttrstr='.'+tempAttrstr;
 
        for(var aItemId in Items) {//index
            var aItem=Items[aItemId];
            //init aResult
            aResult={};
            dx=0;
            dy=0;
            //get x,y
            //dx=aItem[(opt.colX||parserRule.colX)];
            //dy=aItem[(opt.colY||parserRule.colY)];
            dx=eval('aItem'+tempGeomstr+'.'+(opt.colX||parserRule.colX));
            dy=eval('aItem'+tempGeomstr+'.'+(opt.colY||parserRule.colY));
            //get properties
            //console.log('aItem'+tempAttrstr);
            var aPropItem=eval('aItem'+tempAttrstr);
            if(parserList.length==0)
            {
                for(var aCol in aPropItem)
                {
 
                    if(typeof aPropItem[aCol] == "string" )
                    {
                        //eval('aResult.'+aCol+'="'+ aItem[aCol]+'"');
                        aResult[aCol]=aPropItem[aCol];
                    }
                    else if(typeof aPropItem[aCol] == "number")
                    {
                        //eval('aResult.'+aCol+'='+ aItem[aCol]);
                        aResult[aCol]=aPropItem[aCol];
                    }
                    //console.log('aResult.'+aCol+'="'+ aPropItem[aCol]+'"');
                }
            }
            else
            {
                //  [{src:'col1',tar:'hello'}]
                for(var aCol in parserList)
                {
                    if(typeof parserList[aCol.src] == "string" )
                    {
                        aResult[aCol.tar]=parserList[aCol.src];
                        //eval('aResult.'+aCol.tar+'="'+ aItem[aCol.src]+'"');
                    }
                    else if(typeof parserList[aCol.src] == "number")
                    {
                        aResult[aCol.tar]=parserList[aCol.src];
                        //eval('aResult.'+aCol.tar+'='+ aItem[aCol.src]);
                    }
                }
            }
            //console.log('x,y=',dx,dy);
            //combine data
            results.push(({"type":"Feature","geometry":{"type":"Point","coordinates":[dx||0,dy||0]},"properties":aResult}));
 
        }
        var geoJosnParser=new OpenLayers.Format.GeoJSON({
            'internalProjection':opt.targetPrj||parserRule.targetPrj,
            'externalProjection':opt.sourcePrj||parserRule.sourcePrj
        });
        //dbgresults=results;
        //dbgJp=geoJosnParser;
        console.log(geoJosnParser.internalProjection,'<--',geoJosnParser.externalProjection);
        return geoJosnParser.read(({"type":"FeatureCollection","features":(results)}));
 
    }
 
}
//GJSONPARSER^
 
var AProto=function(config)
    {
        var action=function(option){};
        
        this.setAction=function(func_action,newconfig)
        {
            config=  (typeof(newconfig)=='undefined'?config:newconfig);
            action=func_action;
        }
        this.callAction=function(option)
        {
            action(option);
        }
        this.getConfig=function(option)
        {
            return config;
        }
    
    };
 
//CreateLayer (layerType=wms,vector,google)
function createLayer(layerName,config){
    var tmp;
    switch(config.layerType) //wms,vector,google
    {
        case "mapguide":
        
        //var extent = new OpenLayers.Bounds(295199.9995, 2749893.7495, 324028.65675, 2789700.0005);
       
        var options = {
            //  isBaseLayer: true,
            sphericalMercator: true,
              transitionEffect: "resize",
              buffer: 1,
              useOverlay: false,
              useAsyncOverlay: false,
              projection: tw97,
              //maxExtent: extent,
              singleTile: true
          };
        
        
         var engParams = {
         
          mapdefinition: config.layerid,
        //  mapName:"LandMap2",//,OPERATION:"GETPROVIDERCAPABILITIES"
           USERNAME:"Anonymous"
          //session:"5b4cfa12-5db6-11e5-8000-080027009ce6_en_A31D9D110B060B050B04"
          };
       
        
        tmp = new OpenLayers.Layer.MapGuide2(layerName, config.content, engParams, options);
        //tmp.projection="EPSG:3826";
   
        break;
        
        case "wmts":
            var matrixIds =[];
            for (var i=0; i<24; ++i) {
                matrixIds.push( (config.projection||"EPSG:4326") +':' + i);
            }
 
            tmp=new OpenLayers.Layer.WMTS (
                {
                    VERSION:"1.0.0",
                    name: layerName,
                    url: config.content,
                    layer: config.layerid,
                    matrixIds: matrixIds,
                    matrixSet: (config.projection||"EPSG:4326"),
                    style: "_null",   format: "image/png"
                });
            break;
        case "wms":
            tmp=new OpenLayers.Layer.WMS (
                layerName,
                config.content,
                {
 
                    LAYERS: config.layerid,
                    STYLES: '',
                    format: 'image/png8',
                    tiled: config.tiled ||true, //true,
                    //tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom,
                    transparent:config.transparent||true, //true,
                    numZoomLevels: 24 ,
                    tileOptions: {
                        eventListeners: {
                            'beforedraw': function(evt) {
                                // do something on loadend
                                //console.log('beforedraw');
                            } ,
                            'loaderror': function(evt) {
                                // do something on loadend
                                //console.log('loaderror');
                            }
                            ,
                            'loadend': function(evt) {
                                // do something on loadend
                                //console.log('loadend');
                            }
                            ,
                            'loadstart': function(evt) {
                                // do something on loadend
                                //console.log('loadstart');
                            }
                        }
                    }
                    //minScale    :
                },
                {
                    projection:new OpenLayers.Projection(config.projection),
                    isBaseLayer: config.isBaselayer||false,
                    transparent: "true",
                    buffer: 0,
                    displayOutsideMaxExtent: true  ,
                    displayInLayerSwitcher: true    , visibility: false,
                    transitionEffect: 'resize'
                    //  yx : {'EPSG:3826' : false}
                });
            break;
        case "awms":
            tmp=new OpenLayers.Layer.WMS (
                layerName,
                config.content +'/animate',
                {
 
                    LAYERS: config.layerid,
                    STYLES: '',
                    FORMAT: 'image/gif;subtype=animated',
                    FORMAT_OPTIONS: 'antialias:none;gif_loop_continuosly:true;gif_frames_delay:500',
                    REQUEST: 'getmap',
                    SERVICE: 'animate', // MUST BE 'animate'. A 'wms' value will break it!
                    //tiled: config.tiled ||true, //true,
                    //tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom,
                    transparent:config.transparent||true, //true,
                    VERSION: '1.1.1',
                    aparam: 'cql_filter',
                    avalues: '1=0;dt0=20150507,2=2;dt0=20000101',
                    numZoomLevels: 24 ,
                    tileOptions: {
                        eventListeners: {
                            'beforedraw': function(evt) {
                                // do something on loadend
                                //console.log('beforedraw');
                            } ,
                            'loaderror': function(evt) {
                                // do something on loadend
                                //console.log('loaderror');
                            }
                            ,
                            'loadend': function(evt) {
                                // do something on loadend
                                //console.log('loadend');
                            }
                            ,
                            'loadstart': function(evt) {
                                // do something on loadend
                                //console.log('loadstart');
                            }
                        }
                    }
                    //minScale    :
                },
                {
                    projection:new OpenLayers.Projection(config.projection),
                    isBaseLayer: config.isBaselayer||false,
                    transparent: "true",
                    buffer: 0,
                    displayOutsideMaxExtent: true  ,
                    displayInLayerSwitcher: true    , visibility: false,
                    transitionEffect: 'resize'
                    //  yx : {'EPSG:3826' : false}
                });
            break;
        
        case "google":
 
            if(typeof(google)=="undefined")
            {
                tmp=new OpenLayers.Layer.Vector( layerName,
                    {  projection:epsg3857,
                        transparent: "true",
                        buffer: 0,
                        transitionEffect: 'resize',
                        displayOutsideMaxExtent: true ,
                        isBaseLayer: true ,
                        numZoomLevels: 24,
                        displayInLayerSwitcher: true , visibility: false});
            }
            else
            {
                tmp = new OpenLayers.Layer.Google(
                    layerName,
                    {type:(config.content)||google.maps.MapTypeId.ROADMAP ,numZoomLevels: 24, visibility: false, // ,projection: tw97
                        //,maxExtent:googleBound ,
                        //notwork
                        // RESOLUuTIONS: [1.40625,
                        //  serverResolutions: [1.40625,
 
                        transitionEffect: 'resize'
                    },
                    {isBaseLayer: true, buffer: 0  }
                );
            }
            break;
        case "vector" :
            if(typeof(config.styleMap)!="undefined")
            {
                var vInit={styleMap:config.styleMap};
                if(typeof(config.projection)!="undefined")
                     vInit['projection']=config.projection;
                tmp=new OpenLayers.Layer.Vector( layerName,
                    vInit);
            }
            else
            {
                tmp = new OpenLayers.Layer.Vector(layerName,
                 {  styleMap: new OpenLayers.StyleMap({
                        'default': OpenLayers.Util.applyDefaults({
                                strokeWidth: 3,
                                graphicName: 'triangle',
                                pointRadius:6,  //'${radius}',
                                rotation: '${angle}'
                            }, OpenLayers.Feature.Vector.style['default']
                        ),
                        'select': OpenLayers.Util.applyDefaults({
                                pointRadius:6 //'${radius}'
                            }, OpenLayers.Feature.Vector.style['select']
                        )
                    })
                });
            }
            break;
        default:
            console.log('Unsupply LayerType');
            break;
    }
    return tmp;
}
 
function makeResolution(thisLayer,resolutionsLevel)
{
    if(typeof(thisLayer.resolutions)=="undefined") return;
    thisLayer.resolutions.push(thisLayer.resolutions[thisLayer.resolutions.length-1]/2.0)  ;
    if(thisLayer.resolutions.length<resolutionsLevel)  makeResolution(thisLayer,resolutionsLevel)  ;
}
 
function makeScale(thisLayer,scaleLevel)
{
    if(typeof(thisLayer.scales)=="undefined") return;
    if(thisLayer.scales==null)return;
    thisLayer.scales.push(thisLayer.scales[thisLayer.scales.length-1]/2.0)  ;
    if(thisLayer.scales.length<scaleLevel)  makeScale(thisLayer,scaleLevel)  ;
}
 
function findVectorBBox(features)
{
    var maxBoundBox={};
    if(typeof(features)!="undefined")
    {
        for(var idx=0;idx<features.length;idx++)
        {
            features[idx].geometry.calculateBounds();
            if(idx==0)
            {
                maxBoundBox= features[idx].geometry.getBounds(); //or new OpenLayers.Bounds ..
                maxBoundBox['left']=features[idx].geometry.bounds.left;
                maxBoundBox['right']=features[idx].geometry.bounds.right;
                maxBoundBox['top']=features[idx].geometry.bounds.top;
                maxBoundBox['bottom']=features[idx].geometry.bounds.bottom;
            }else
            {
                maxBoundBox['left']=features[idx].geometry.bounds.left<maxBoundBox['left']?features[idx].geometry.bounds.left:maxBoundBox['left'];
                maxBoundBox['right']=features[idx].geometry.bounds.right>maxBoundBox['right']?features[idx].geometry.bounds.right:maxBoundBox['right'];
                maxBoundBox['top']=features[idx].geometry.bounds.top<maxBoundBox['top']?features[idx].geometry.bounds.top:maxBoundBox['top'];
                maxBoundBox['bottom']=features[idx].geometry.bounds.bottom>maxBoundBox['bottom']?features[idx].geometry.bounds.bottom:maxBoundBox['bottom'];
 
            }
        }
 
    }
    return maxBoundBox;
}
 
 
var extMapResultion=function(thismap,resolutionsLevel)//太高會有alias問題
{
    var layerkey;
    var aLayer;
 
    
    
    for (layerkey in thismap.layers)
    {
        aLayer=  thismap.layers[layerkey] ;
        makeResolution (aLayer,resolutionsLevel);
        makeScale (aLayer,resolutionsLevel);
        if(aLayer.scales==null) return;
        if(typeof(aLayer.scales)!="undefined"){
        aLayer.maxScale=aLayer.scales[aLayer.scales.length-1] ;
        aLayer.minResolution=aLayer.resolutions[aLayer.resolutions.length-1] ;
        aLayer.numZoomLevels = resolutionsLevel;
    }
    }
 
};
var CtlCopyFeatures=function(desLayer,config)
{
    if(typeof(config)=="undefined")config={};
    
    this.action=function(option){
        if (typeof(option)=="undefined")option={};
        var resultData={};
        // !! fromProjection !!
        var wktReader=new OpenLayers.Format.WKT({
            'internalProjection':option.toprojection ||desLayer.projection ,    //target
            'externalProjection':option.formprojection|| desLayer.projection          //src
        });
        
        if(option.clearAll)
        {
            desLayer.destroyFeatures();
        }
        //add features
        if(typeof(option.features)!="undefined")
        {
            
            for(var idxOfFeatures=0 ;idxOfFeatures<option.features.length;idxOfFeatures++)
            {
                var aFeature=wktReader.read(option.features[idxOfFeatures].geometry.toString());    
                    aFeature["attributes"]=option.features[idxOfFeatures].attributes;
                
                if(typeof(option.features[idxOfFeatures].attributes)!="undefined")
                {
                    for(var aAttrib in option.features[idxOfFeatures].attributes)
                    {
                        aFeature.attributes[aAttrib]=option.features[idxOfFeatures].attributes[aAttrib];
                    }
                }    
                
                desLayer.addFeatures(aFeature);
                
            }
        }
            
    }
    this.cancel=function(config){
        if(typeof(config)=="undefined")config={};
        desLayer.destroyFeatures();
           
    }
}
var DGNParser=function()
{
    var transforNum=function( x,  y)
    {
        var num = "";
        if (x >= 0 && x <= 99 && y >= 0 && y <= 99)
        {
        if (x < 10)
            num = "0" + String(x);
        else
            num = String(x);
        if (y < 10)
            num = num + "0" + String(y);
        else
            num = num + String(y);
        }
    return (num);
    }
    this. get1000=function(dx,dy)
    {
    var x, y;
    num = "";
    x = parseInt((parseInt( dx) - 270400) / 800);
    y = parseInt((parseInt( dy)- 2743500) / 600);
    num = transforNum(x, y);
    return (num);
    }
  
    this. get500=function( dx,  dy)
    {
    var x, y, ofx, ofy;
    var num = "";
 
    x = parseInt((parseInt( dx )- 270400) / 800);
    y = parseInt((parseInt( dy )- 2743500) / 600);
    num = transforNum(x, y);
    ofx = parseInt((dx - x * 800 - 270400) / 400);
    ofy = parseInt((dy - y * 600 - 2743500) / 300);
    if (ofx != 0 && ofy != 0)
        num = num + "A";
    else if (ofx != 0 && ofy == 0)
        num = num + "B";
    else if (ofx == 0 && ofy == 0)
        num = num + "C";
    else if (ofx == 0 && ofy != 0)
        num = num + "D";
    return (num);
    }
}
var dgnParser=new DGNParser();
var CtlGetWKT=function(scope,config)
{
    if(typeof(config)=="undefined")config={};
    
    this.parser=function(feature,option)
    {
        if (typeof(option)=="undefined")option={};
        var wktReader=new OpenLayers.Format.WKT({
            'internalProjection':option.toprojection ||tw97,    //target
            'externalProjection':option.formprojection|| scope.projection          //src
        });
        if ('featurePoint' == option.geometryType || 'featurePoint') {
            var geom = wktReader.read(feature.geometry.toString());
            var resultobj = { wkt: geom.geometry.toString() };
            if (wktReader.internalProjection == tw97) {
                resultobj["dgnid1000"] = dgnParser.get1000(geom.geometry.x, geom.geometry.y);
                resultobj["dgnid500"] = dgnParser.get500(geom.geometry.x, geom.geometry.y);
            }
            resultobj["point"] = { x: geom.geometry.x, y: geom.geometry.y };
            return resultobj;
        }
    }
    
    
    this.action=function(option){
        if (typeof(option)=="undefined")option={};
        var resultData={};
        var wktReader=new OpenLayers.Format.WKT({
            'internalProjection':option.toprojection ||tw97,    //target
            'externalProjection':option.formprojection|| scope.projection          //src
        });
        
        //wktReader.read(dwc1.getMap() .layers[10].features[0].geometry)
        var srcLayer=config.srcLayer||'drawTemp';
        var workLayers=scope.getLayersByName(srcLayer);
        if(workLayers.length==0)
            return resultData;
            // parser97DGNID: true, extactPoints: true
            //dwc1.getWkt({parser97DGNID:true}).bounds.dgnid500
        var tempPoints=[];
        var featureData=[];
        var boundOfWkt={left:0,right:0,top:0,buttom:0};
 
        //不支援空心圖
        for(var idxOfFeatures=0 ;idxOfFeatures<workLayers[0].features.length;idxOfFeatures++)
        {
            var tempWkt1=wktReader.read(workLayers[0].features[idxOfFeatures].geometry.toString());    
            var tempfeature;
            
            if('wkt'==config.resultFormat||'wkt')
            {
                //for(var idx=0;idx<tempWkt0.length;idx++)
                //findVectorBBox 因為還是會跑一次..下面比較快
                tempWkt1.geometry.calculateBounds();
            
                if(idxOfFeatures==0){
                    //resultData["features"]=[];
                    boundOfWkt.left=tempWkt1.geometry.bounds.left;
                    boundOfWkt.right=tempWkt1.geometry.bounds.right;
                    boundOfWkt.top=tempWkt1.geometry.bounds.top;
                    boundOfWkt.buttom=tempWkt1.geometry.bounds.buttom;
                }else
                {
                    if(tempWkt1.top>boundOfWkt.top)boundOfWkt.top=tempWkt1.top;
                    if(tempWkt1.right>boundOfWkt.right)boundOfWkt.right=tempWkt1.right;
                    if(tempWkt1.left<boundOfWkt.left)boundOfWkt.left=tempWkt1.left;
                    if(tempWkt1.buttom<boundOfWkt.buttom)boundOfWkt.buttom=tempWkt1.buttom;
                    
                }
                
                tempfeature={
                info:workLayers[0].features[idxOfFeatures].attributes,
                wkt:tempWkt1.geometry.toString()
                };
                                
            }
            
            //if(option.extactPoints||false)
            {
                tempfeature['points']=tempWkt1.geometry.getVertices();
            }
            if(option.parser97DGNID||false)
            {
            var vpoint0s=tempWkt1.geometry.getVertices();
                if(vpoint0s.length>0)
                {
                    boundOfWkt['dgnid500']=dgnParser.get500(vpoint0s[0].x,vpoint0s[0].y);
                    boundOfWkt['dgnid1000']=dgnParser.get1000(vpoint0s[0].x,vpoint0s[0].y);
                }
                
            }
 
            featureData.push(tempfeature);
            
            //return resultData;
        }
        return {features:featureData,bounds:boundOfWkt};
    }
    this.cancel=function(config){
    if(typeof(config)=="undefined")config={};
    var vLayer=scope.getLayersByName(config.layer||"drawTemp");
      vLayer[0].destroyFeatures();
       
    }
}
var CtlLocate=function(scope,config){
    //var zoomCtl=new OpenLayers.Control.ZoomBox();
 
    if(typeof(config)=="undefined")config={};
    //var wkt=wktgoogleFrom67;
    this.action=function(option)   // {point:{x,y}}  {pts:[xy xy xy ]} ,wkt
    // drawAs: point /line /polygon
    // zoomToView
    {
        var points=[];
        var buffSize=0;
        var wkt=new OpenLayers.Format.WKT({
            'internalProjection':scope.projection ,    //target
            'externalProjection': option.projection||tw97          //src
        });
        
        if(typeof(option.buffsize)!="undefined") {
            buffSize= parseFloat (buffsize);
        }
        if(typeof(option.point)!="undefined"){
            points.push(parseFloat(option.point.x));
            points.push(parseFloat(option.point.y));
        }
        if(typeof(option.points)!="undefined"){
            for(var idx=0;idx<option.points.length;idx++)
            {
                var tmp= option.points[idx];
                points.push(parseFloat(tmp.x));
                points.push(parseFloat(tmp.y));
            }
        }
        if(typeof(option.pts)!="undefined") {
            for(var idx=0;idx<option.pts.length;idx+=2)
            {
                points.push(parseFloat(option.pts[idx]));
                points.push(parseFloat(option.pts[idx+1]));
            }
        }
        var setFeature=function(vFeature)
        {
            var currStyle=null;
            if(typeof(option.style)!="undefined") {
                currStyle=option.style;
                OpenLayers.Util.applyDefaults(currStyle,OpenLayers.Feature.Vector.style["default"]); 
            }
            
            if(typeof(option.attributes)!="undefined")
            {
                for(var aAttrib in option.attributes)
                {
                    vFeature.attributes[aAttrib]=option.attributes[aAttrib];
                }
            }
            else
            {
                vFeature.attributes={};
            }
            if(typeof(vFeature.attributes.descript)=="undefined")
            {
                vFeature.attributes["descript"]="";
            }
            if(typeof(vFeature.attributes.popup)=="undefined")
            {
                vFeature.attributes["popup"]="";
            }
            if(currStyle!=null)
            {
                vFeature.style=currStyle;
            }
            
        }
        //console.log(points);
        //console.log(option)
        var vFeature;
        var vLayer=scope.getLayersByName(config.layer||"markup");
        //var wkt=wkt67To97;
        if(option.clearAll||false)
        {
            vLayer[0].destroyFeatures();
        }
        if(option.drawAs=='lineGrid') {
 
            var tmp= "LINESTRING(";
 
            if(points.length==2)
            {
                var bufTemp=parseFloat(buffSize>0?buffSize:5);
                tmp+=(points[0]-bufTemp+" "+points[1]-bufTemp+",");
                tmp+=(points[0]+bufTemp+" "+points[1]-bufTemp+",");
                tmp+=(points[0]+bufTemp+" "+points[1]+bufTemp+",");
                tmp+=(points[0]-bufTemp+" "+points[1]+bufTemp+",");
                tmp+=(points[0]-bufTemp+" "+points[1]-bufTemp+")");
            }else if(points.length==4){
                var bufTemp=parseFloat(buffSize>0?buffSize:0);
 
                tmp+=((points[0]-bufTemp)+" "+(points[1]-bufTemp+","));
                tmp+=((points[2]+bufTemp)+" "+(points[1]-bufTemp+","));
                tmp+=((points[2]+bufTemp)+" "+(points[3]+bufTemp+","));
                tmp+=((points[0]-bufTemp)+" "+(points[3]+bufTemp+","));
                tmp+=((points[0]-bufTemp)+" "+(points[1]-bufTemp+")"));
            }else if(points.length==8||points.length==10){
                var bufTemp=parseFloat(buffSize>0?buffSize:0);
                tmp=tmp+points[0]-bufTemp+" "+points[1]-bufTemp+",";
                tmp=tmp+points[2]+bufTemp+" "+points[3]-bufTemp+",";
                tmp=tmp+points[4]+bufTemp+" "+points[5]+bufTemp+",";
                tmp=tmp+points[6]-bufTemp+" "+points[7]+bufTemp+",";
                tmp=tmp+points[0]-bufTemp+" "+points[1]-bufTemp+")";
            }else{
                tmp=tmp+"0 0)";
            }
            //console.log(tmp);
            vFeature=wkt.read(tmp);
            setFeature(vFeature);
            vLayer[0].addFeatures(vFeature);
        }else if(option.drawAs=='line'){
            var tmp= "LINESTRING(";
            var bufTemp=0;
            for(var idx=0;idx<points.length;idx+=2)
            {
                if(idx>0)
                {
                    tmp=tmp+",";
                }
                tmp=tmp+points[idx]+" "+points[idx+1];
            }
            tmp=tmp+")";
            vFeature=wkt.read(tmp);
            setFeature(vFeature);
            vLayer[0].addFeatures(vFeature);
        }else if(option.drawAs=='polygon'){
            var tmp= "POLYGON((";
            var bufTemp=0;
            for(var idx=0;idx<points.length;idx+=2)
            {
                if(idx>0)
                {
                    tmp=tmp+",";
                }
                tmp=tmp+points[idx]+" "+points[idx+1];
            }
            if(points[0]!=points[points.length-2] && points[1]!=points[points.length-1])
            {
                tmp=tmp+","+points[0]+" "+points[1];
            }
            tmp=tmp+"))";
            vFeature=wkt.read(tmp);
            setFeature(vFeature);
            vLayer[0].addFeatures(vFeature);
 
        }
        else if(option.drawAs=='point'||option.drawAs=='mpoint') {
            var tmp;
            var bufTemp=0;
                 for(var idx=0;idx<points.length;idx+=2)
                 {
                     tmp="POINT("+points[idx]+" "+points[idx+1]+")";
                     
                     vFeature=wkt.read(tmp);
                     setFeature(vFeature);
                     vLayer[0].addFeatures(vFeature);
                     //vLayer[0].addFeatures( wkt.read(tmp));
                 }
        }   else if(option.drawAs=='wkt') {
            var tmp=option.wkt;
            var bufTemp=0;
            if(typeof(tmp)!="undefined") {
            vFeature=wkt.read(tmp);
            setFeature(vFeature);
            vLayer[0].addFeatures(vFeature);
            //vLayer[0].addFeatures( wkt.read(tmp));
            }
        }
 
        vLayer[0].setVisibility(true);
 
        // var zoomNum= scope.getZoomForExtent(featuresBound);
        if(option.zoomToCenter||false)
        {
            var zoomLv=option.zoomLevel||19;
 
            var extRange=findVectorBBox(vLayer[0].features );//vLayer[0].getExtent();
 
            scope.setCenter(new OpenLayers.LonLat((extRange.left+extRange.right)/2,(extRange.top+extRange.bottom)/2)
              //  .transform(config.projection, scope.getProjectionObject())
              ,zoomLv);
        }else if (option.zoomToRange||false)
        {
            //debugger;
            //vLayer[0].getExtent(); is error (CAL)
            var extRange=findVectorBBox(vLayer[0].features )
            var zoomNum= scope.getZoomForExtent(extRange);
            //debugger;
            scope.setCenter(new OpenLayers.LonLat((extRange.left+extRange.right)/2,(extRange.top+extRange.bottom)/2),zoomNum);
        }
 
        if(option.drawTempLayer||false)
        {
            vLayer[0].destroyFeatures();
        }
    };
    this.cancel=function(config){
    if(typeof(config)=="undefined")config={};
    var vLayer=scope.getLayersByName(config.layer||"markup");
      vLayer[0].destroyFeatures();
    } ;
}