text:
<!DOCTYPE HTML>

<title>LETSTREKHIMALAYA - A guide to your dreams...</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all">
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Travel Guide, Trekking,Himalays,Himachal Pradesh,Hiking,Trek in Himalayas,
Camping in Himalayas,Camping, Tent, River Rafting, Cycling, Biking, Mountain" />

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700,800' rel='stylesheet' type='text/css'>

<link rel="stylesheet" href="css/swipebox.css">

					  <form>
						 <input type="text" value="" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search..';}"/>
						 <input type="submit" value="">
					  </form>

Registration

Login

						---------------
Let's Trek Himalayas
---------------

Expeditions, Trekking, Camping...

Home

About

News

Events

Blog

Contacts

NEW CUSTOMERS

By creating an account with us, you will be able to move through the checkout process faster, view your previous adventures in your account , get notified with the latest news and events and more...

					Create an Account

REGISTERED CUSTOMERS

If you have an account with us, please log in.

					<form>

							Email Address*
							<input type="text">

							Password*
							<input type="text">

						Forgot Your Password?
						<input type="submit" value="Login">
					</form>

Information

About

News

Events

Blog

Contacts

follow us

Email updates

Give us your email so that we can keep you updated with the latest news and events

						<form>
							<input type="text" class="text" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}">
						</form>

Contact us

Saurabh Jain

letstrekhimalayas@gmail.com

Tel   : +91 9999 88 7619

Copyrights © 2016 LETSTREKHIMALAYA - All rights reserved


text:
package sunshine.ferdyrodriguez.com.sunshine;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.test.AndroidTestCase;
import android.util.Log;

import sunshine.ferdyrodriguez.com.sunshine.data.WeatherContract.LocationEntry;
import sunshine.ferdyrodriguez.com.sunshine.data.WeatherContract.WeatherEntry;
import sunshine.ferdyrodriguez.com.sunshine.data.WeatherDbHelper;

/**
 * Created by apple on 27/07/14.
 */
public class TestProvider extends AndroidTestCase {

    public static final String TAG = TestProvider.class.getSimpleName();

    public void testDeleteDb() throws Throwable {
        mContext.deleteDatabase(WeatherDbHelper.DATABASE_NAME);
    }

    public void testInsertReadProvider() {
        String testName = "North Pole";
        String testLocationSetting = "99705";
        Double testLatitude = 62.772;
        Double testLongitude = -147.355;

        WeatherDbHelper dbHelper = new WeatherDbHelper(mContext);
        SQLiteDatabase db = dbHelper.getWritableDatabase();

        ContentValues values = new ContentValues();
        values.put(LocationEntry.COLUMN_CITY_NAME, testName);
        values.put(LocationEntry.COLUMN_LOC_SETTING, testLocationSetting);
        values.put(LocationEntry.COLUMN_COORD_LAT, testLatitude);
        values.put(LocationEntry.COLUMN_COORD_LONG, testLongitude);

        long locationRowId;
        locationRowId = db.insert(LocationEntry.TABLE_NAME, null, values);

        assertTrue(locationRowId != -1);
        Log.d(TAG, "New row id: " + locationRowId);

        String[] columns = {
                LocationEntry._ID,
                LocationEntry.COLUMN_LOC_SETTING,
                LocationEntry.COLUMN_CITY_NAME,
                LocationEntry.COLUMN_COORD_LAT,
                LocationEntry.COLUMN_COORD_LONG
        };

        Cursor cursor = mContext.getContentResolver().query(LocationEntry.CONTENT_URI,
                null,
                null,
                null,
                null
        );

/*        Cursor cursor = mContext.getContentResolver().query(
                LocationEntry.buildLocationUri(locationRowId),
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                null  // sort order
        );*/

        if (cursor.moveToFirst()) {
            int locationIndex = cursor.getColumnIndex(LocationEntry.COLUMN_LOC_SETTING);
            String location = cursor.getString(locationIndex);

            int nameIndex = cursor.getColumnIndex(LocationEntry.COLUMN_CITY_NAME);
            String name = cursor.getString(nameIndex);

            int latitudeIndex = cursor.getColumnIndex(LocationEntry.COLUMN_COORD_LAT);
            Double latitude = cursor.getDouble(latitudeIndex);

            int longitudeIndex = cursor.getColumnIndex(LocationEntry.COLUMN_COORD_LONG);
            Double longitude = cursor.getDouble(longitudeIndex);

            assertEquals(testName, name);
            assertEquals(testLocationSetting, location);
            assertEquals(testLatitude, latitude);
            assertEquals(testLongitude, longitude);

            ContentValues weatherValues = new ContentValues();
            weatherValues.put(WeatherEntry.COLUMN_LOC_KEY, locationRowId);
            weatherValues.put(WeatherEntry.COLUMN_DATETEXT, "20141205");
            weatherValues.put(WeatherEntry.COLUMN_DEGREES, 1.1);
            weatherValues.put(WeatherEntry.COLUMN_HUMIDITY, 1.2);
            weatherValues.put(WeatherEntry.COLUMN_PRESSURE, 1.3);
            weatherValues.put(WeatherEntry.COLUMN_MAX_TEMP, 75);
            weatherValues.put(WeatherEntry.COLUMN_MIN_TEMP, 65);
            weatherValues.put(WeatherEntry.COLUMN_SHORT_DESC, "Asteroids");
            weatherValues.put(WeatherEntry.COLUMN_WIND_SPEED, 5.5);
            weatherValues.put(WeatherEntry.COLUMN_WEATHER_ID, 321);

            long weatherRowId;
            weatherRowId = db.insert(WeatherEntry.TABLE_NAME, null, weatherValues);
            assertTrue(weatherRowId != -1);

            Cursor weatherCursor = mContext.getContentResolver().query(WeatherEntry.CONTENT_URI,
                    null,
                    null,
                    null,
                    null
            );

            if (weatherCursor.moveToFirst()) {
                assertEquals(weatherCursor.getInt(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_LOC_KEY)), locationRowId);
                assertEquals(weatherCursor.getString(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_DATETEXT)), "20141205");
                assertEquals(weatherCursor.getDouble(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_DEGREES)), 1.1);
                assertEquals(weatherCursor.getDouble(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY)), 1.2);
                assertEquals(weatherCursor.getDouble(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_PRESSURE)), 1.3);
                assertEquals(weatherCursor.getInt(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP)), 75);
                assertEquals(weatherCursor.getInt(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP)), 65);
                assertEquals(weatherCursor.getString(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC)), "Asteroids");
                assertEquals(weatherCursor.getDouble(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED)), 5.5);
                assertEquals(weatherCursor.getInt(
                        weatherCursor.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID)), 321);
            } else {
                fail("No weather data returned!");
            }

            weatherCursor.close();

        } else {
            fail("No values returned :(");
        }

        cursor.close();
        dbHelper.close();
    }

    public void testGetType() {
        // content://com.example.android.sunshine.app/weather/
        String type = mContext.getContentResolver().getType(WeatherEntry.CONTENT_URI);
        // vnd.android.cursor.dir/com.example.android.sunshine.app/weather
        assertEquals(WeatherEntry.CONTENT_TYPE, type);

        String testLocation = "94074";
        // content://com.example.android.sunshine.app/weather/94074
        type = mContext.getContentResolver().getType(
                WeatherEntry.buildWeatherLocation(testLocation));
        // vnd.android.cursor.dir/com.example.android.sunshine.app/weather
        assertEquals(WeatherEntry.CONTENT_TYPE, type);

        String testDate = "20140612";
        // content://com.example.android.sunshine.app/weather/94074/20140612
        type = mContext.getContentResolver().getType(
                WeatherEntry.buildWeatherLocationWithDate(testLocation, testDate));
        // vnd.android.cursor.item/com.example.android.sunshine.app/weather
        assertEquals(WeatherEntry.CONTENT_ITEM_TYPE, type);

        // content://com.example.android.sunshine.app/location/
        type = mContext.getContentResolver().getType(LocationEntry.CONTENT_URI);
        // vnd.android.cursor.dir/com.example.android.sunshine.app/location
        assertEquals(LocationEntry.CONTENT_TYPE, type);

        // content://com.example.android.sunshine.app/location/1
        type = mContext.getContentResolver().getType(LocationEntry.buildLocationUri(1L));
        // vnd.android.cursor.item/com.example.android.sunshine.app/location
        assertEquals(LocationEntry.CONTENT_ITEM_TYPE, type);
    }
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>CodeRay output</title>

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
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063

define.class('$ui/view', function(require, $ui$, view, label, button, labelset, $$, geo, urlfetch)
{

        var BufferGen = require('$widgets/map/mapbuffers')()
        var geo = this.geo = geo()
        var ubuntufont = require('$resources/fonts/ubuntu_medium_256_baked.glf')

        this.attributes = {
                // TODO(aki): Why latlong inverse?
                latlong:  Config({type: vec2, value: vec2(52.3608307, 4.8626387)}),
                zoomlevel: Config({type: Number, value: 16}),
                latlongchange: Config({type: Event}),
                showlabels: Config({type: Boolean, value: false})
        }

        function createHash (x, y, z) {
                return x + '_' + y + '_' + z
        }

        this.zoomTo = function(z, time) {
                this.dataset.zoomTo(z, time)
        }

        this.onpointerwheel = function(ev) {
                if (!ev.touch) {
                        this.zoomTo(this.dataset.zoomlevel - ev.wheel[1] / 120)
                        this.clearTimeout(this.zoomTimeout)
                        this.zoomTimeout = this.setTimeout(function() {
                                this.emitUpward('latlongchange', [this.latlong[0], this.latlong[1], this.zoomlevel])
                        }.bind(this), 100)
                }
        }

        this.onpointerstart = function(ev) {
                this.dragging = true
        }

        this.onpointermultimove = function(ev) {
                if (!this.dragging) return
                if (ev.length == 1) {
                        this.panByVectorMovement(ev[0].position, ev[0].movement)
                } else if (ev.length == 2) {
                        var center = vec2.mix(ev[0].position, ev[1].position, 0.5)
                        var movement = vec2.mix(ev[0].movement, ev[1].movement, 0.5)
                        this.panByVectorMovement(center, movement)
                        var distance = vec2.distance(ev[0].position, ev[1].position)
                        var distanceOld = vec2.distance(
                                vec2.sub(ev[0].position, ev[0].movement),
                                vec2.sub(ev[1].position, ev[1].movement)
                        )
                        var distanceDelta = (distance - distanceOld) / this.layout.width * 5
                        this.zoomTo(this.dataset.zoomlevel + distanceDelta)
                }
        }

        this.panByVectorMovement = function (vector, movement) {
                var startPos = vec2.sub(vector, movement)
                var R = this.projectonplane(this.globalToLocal(startPos))
                if (R) {
                        this.prevvect = vec2(R[0] / (BufferGen.TileSize * 16), R[2] / (BufferGen.TileSize * 16))
                }
                R = this.projectonplane(this.globalToLocal(vector));
                if (R) {
                        this.newvect = vec2(R[0] / (BufferGen.TileSize * 16),R[2] / (BufferGen.TileSize * 16))
                        var metoffset = vec2(
                                (this.newvect[0] - this.prevvect[0]) * geo.metersPerTile(this.zoomlevel) * Math.pow(2.0, -this.fraczoom),
                                -(this.newvect[1] - this.prevvect[1]) * geo.metersPerTile(this.zoomlevel) * Math.pow(2.0, -this.fraczoom)
                        )
                        var latlongoffset = geo.metersToLatLng(metoffset[0], metoffset[1])
                        this.dataset.setCenterLatLng(
                                this.dataset.latlong[0] - latlongoffset[0],
                                this.dataset.latlong[1] - latlongoffset[1],
                                this.dataset.zoomlevel)
                        this.updateTiles()
                }
        }

        this.onpointerend = function(ev) {
                this.dragging = false
                this.emitUpward('latlongchange', [this.latlong[0], this.latlong[1], this.zoomlevel])
        }

        this.onpointertap = function(ev) {
                var coord  =  this.globalToLocal(ev.position)
                var R = this.projectonplane(coord)
                if (R) {
                        var centermeters = geo.latLngToMeters(this.dataset.latlong[0], this.dataset.latlong[1])
                        var zoomoffs = 0
                        if (ev.clicker == 2) zoomoffs ++
                        // convert GL unit to map meters
                        var r0 = (R[0] / (BufferGen.TileSize * 16)) * geo.metersPerTile(this.zoomlevel) * Math.pow(2.0, -this.fraczoom)
                        var r2 = (-R[2] / (BufferGen.TileSize * 16)) * geo.metersPerTile(this.zoomlevel) * Math.pow(2.0, -this.fraczoom)
                        //        var M = this.find('MARKER')
                        var latlong = geo.metersToLatLng(centermeters[0] + r0, centermeters[1] + r2)
                        this.dataset.setCenterLatLng(latlong[0], latlong[1] , this.dataset.zoomlevel + zoomoffs, 1)
                        this.emitUpward('latlongchange', [latlong[0], latlong[1], this.zoomlevel])
                }
        }

        this.gotoCity = function(city, zoomlevel, time) {
                this.dataset.gotoCity(city, zoomlevel, time)
        }

        this.flyTo = function(lat, lng, zoom, time) {
                if (this.dataset) this.dataset.flyTo(lat, lng, zoom, time)
        }

        this.framePoints = function(points, time) {
                if (this.dataset) this.dataset.framePoints(points, time)
        }

        // data interaction, needs to inherit from view because of animation
        define.class(this, 'mapdataset', '$ui/view', function($$, geo) {

                this.requestPending = false
                // all the blocks that need to be loaded (empty tile objects)
                this.loadqueue = []
                // see if a block is in the queue (array of hashes)
                this.loadqueuehash = []
                // hash of tile objects (simple objects containing all the geometry)
                this.loadedblocks = {}
                // geo library
                var geo = this.geo = geo()

                this.attributes = {
                        // cent
                        centerpos: vec2(0, 0),
                        // position of the map
                        latlong: vec2(0, 0),
                        // tile zoom level
                        zoomlevel: 16,
                        // amount of blocks in the cache
                        throwawaythreshold: 100,
                }

                // animatedly fly to a lat/long/zoom position in time with fly bounce (zoom level switching)
                this.flyTo = function(lat, lng, zoom, time) {
                        time = time ? time : 0
                        if (zoom > geo.default_max_zoom) zoom = geo.default_max_zoom

                        if (time > 0) {
                                var anim = {}
                                anim[time] = {motion: 'inoutquad', value: vec2(lat, lng)}
                                this.latlong = Animate(anim)
                                var anim = {}
                                // anim[time / 2] = {motion: 'inoutquad', value: Math.min(zoom - 0.5, this.zoomlevel - 0.5)}
                                anim[time] = {motion: 'inoutquad', value: zoom}
                                this.zoomlevel = Animate(anim)
                        } else {
                                this.zoomlevel = zoom
                                this.latlong = vec2(lat, lng)
                        }
                }

                this.framePoints = function(pointdata, time) {
                        sum = vec2(0, 0)
                        maxpos = vec2(-Infinity, -Infinity)
                        minpos = vec2(Infinity, Infinity)
                        // TODO: lan/lng is swapped. Fix map.js
                        for (var i = 0; i < pointdata.length; i ++){
                                sum[1] = sum[1] + pointdata[i].latitude
                                sum[0] = sum[0] + pointdata[i].longitude
                                maxpos[1] = max(maxpos[1], pointdata[i].latitude)
                                maxpos[0] = max(maxpos[0], pointdata[i].longitude)
                                minpos[1] = min(minpos[1], pointdata[i].latitude)
                                minpos[0] = min(minpos[0], pointdata[i].longitude)
                        }
                        maxpos = geo.latLngToMeters(maxpos[0], maxpos[1])
                        minpos = geo.latLngToMeters(minpos[0], minpos[1])
                        var distance = vec2.distance(maxpos, minpos)
                        var zoom = geo.default_max_zoom
                        // TODO: make frustum aware zoom level estimation
                        if (distance < 312) zoom = 15
                        else if (distance < 625) zoom = 14
                        else if (distance < 1250) zoom = 13
                        else if (distance < 2500) zoom = 12
                        else if (distance < 5000) zoom = 11
                        else if (distance < 10000) zoom = 10
                        else if (distance < 20000) zoom = 10
                        else if (distance < 40000) zoom = 9
                        else if (distance < 80000) zoom = 8
                        else if (distance < 160000) zoom = 7
                        else if (distance < 320000) zoom = 6
                        else if (distance < 640000) zoom = 5
                        else if (distance < 128000) zoom = 4
                        else if (distance < 256000) zoom = 3
                        else if (distance < 512000) zoom = 2
                        else if (distance < 1024000) zoom = 1
                        this.flyTo(sum[0] / pointdata.length, sum[1] / pointdata.length, zoom, time)
                }

                // animatedly fly to lat/long without fly-bouncing
                this.setCenterLatLng = function(lat, lng, zoom, time) {
                        time = time ? time : 0
                        if (zoom > geo.default_max_zoom) zoom = geo.default_max_zoom
                        if (time > 0) {
                                var anim = {}
                                anim[time] = {motion: 'inoutquad', value: vec2(lat,lng)}
                                this.latlong = Animate(anim)
                        } else {
                                this.latlong = vec2(lat,lng)
                        }
                        this.zoomTo(zoom, time)
                }

                // if zoomlevel changes update tiles
                this.onzoomlevel = function() {
                        if (this.parent) {
                                this.parent.updateTiles()
                        }
                }

                // latlong changes, for all zoomlevels calculate tile centers
                this.onlatlong = function() {
                        if(!this.latlong) return
                        this.parent.latlong = this.latlong
                        var m = geo.latLngToMeters(this.latlong[0], this.latlong[1])
                        m[0] = Math.round(m[0])
                        m[1] = Math.round(m[1])
                        var basecenter = geo.tileForMeters(m[0], m[1], 20)
                        var compmeters = geo.metersForTile({x: basecenter[0],y: basecenter[1], z: 20})

                        var centerset = []
                        for (var i = 0; i < 20; i ++) {
                                var center = geo.tileForMeters(m[0], m[1], i)
                                centerset.push([center.x, center.y])
                        }
                        this.centers = centerset
                }

                // zoom to animatedly zooms to a certain zoom
                this.zoomTo = function(newz, time) {
                        if (newz > geo.default_max_zoom) newz = geo.default_max_zoom

                        time = time? time : 0
                        if (time > 0) {
                                var anim = {}
                                anim[time] = {motion: 'inoutquad', value: newz}
                                this.zoomlevel = Animate(anim)
                        } else {
                                this.zoomlevel = newz
                        }
                }

                // set the center in tile position x/y/zoom, uses to setCenterLatLng
                this.setCenter = function(x,y,z, time) {
                        var m = geo.metersForTile({x: x, y: y, z: z})
                        var ll = geo.metersToLatLng(m.x,m.y)
                        this.setCenterLatLng(ll[0], ll[1], time)
                        this.zoomTo(z, time)
                }

                // queues up a block for loading at x,y,z
                this.addToQueue = function(x, y, z) {
                        if (x < 0 || y < 0 || z< 0 || z>geo.default_max_zoom) return
                        var hash = createHash(x, y, z)
                        if (this.loadqueuehash[hash]) return; // already queued for load.
                        if (this.loadedblocks[hash]) return; // already loaded.

                        this.loadqueuehash[hash] = 1
                        this.loadqueue.push({x: x, y: y, z: z})
                        this.updateLoadQueue()
                }

                // Stores a loaded block into the loadedblocks structure
                this.processLoadedBlock = function(x, y, z, data) {
                        var hash = createHash(x,y,z)
                        this.loadedblocks[hash] = {x: x, y: y, z: z, blockdata: data}
                }

                // prunes the loadedblocks to live below throwawaythreshold
                this.cleanLoadedBlocks = function() {
                        var keys = Object.keys(this.loadedblocks)
                        if (keys.length < this.throwawaythreshold) return

                        var zscalar = 1280

                        var dellist = []
                        for (var i = 0; i < keys.length; i ++) {
                                        var q = this.loadedblocks[keys[i]]
                                        var dx = this.centers[q.z][0] - q.x
                                        var dy = this.centers[q.z][1] - q.y

                                        var dz = (20-q.z) * zscalar
                                        var dist = (dx * dx + dy * dy) * (50000 - dz)
                                        dellist.push({hash: keys[i], dist: dist})

                                }

                                dellist = dellist.sort(function(a, b) {
                                        if (a.dist > b.dist) return 1
                                        if (a.dist < b.dist) return -1
                                        return 0
                                })

                        for (var i = this.throwawaythreshold; i < dellist.length; i ++) {
                                var todelete = dellist[i]
                                var blk = this.loadedblocks[todelete.hash]
                                delete this.loadedblocks[todelete.hash]
                                if (blk.buildingVertexBuffer) {
                                        if (blk.buildingVertexBuffer.glvb) {
                                                this.screen.device.gl.deleteBuffer(blk.buildingVertexBuffer.glvb)
                                                blk.buildingVertexBuffer.glvb = undefined
                                        }
                                        if (blk.landVertexBuffer.glvb) {
                                                this.screen.device.gl.deleteBuffer(blk.landVertexBuffer.glvb)
                                                blk.landVertexBuffer.glvb = undefined
                                        }
                                        if (blk.roadVertexBuffer.glvb) {
                                                this.screen.device.gl.deleteBuffer(blk.roadVertexBuffer.glvb)
                                                blk.roadVertexBuffer.glvb = undefined
                                        }
                                }
                        }
                }

                // the geometry generation worker
                var worker = define.class('$system/rpc/worker', function(require) {
                        this.BufferGen = require('$widgets/map/mapbuffers')()

                        this.build = function(str, r) {
                                var ret = vec2.array(10)

                                try{
                                        var thedata = JSON.parse(str)
                                        this.BufferGen.build(r, thedata)
                                }
                                catch(e) {
                                        console.log(e)
                                        console.log(' while loading ', r.x, r.y, r.z)
                                        r.transform = {translate: {x: 0, y: 0}}
                                }
                                return r
                        }
                })

                // loads a json string tile and sends it off to the worker
                this.loadstring = function(str) {
                        // if (!window.teller) window.teller = 0
                        // window.teller += str.length

                        if (this.currentRequest) {

                                var r = this.currentRequest
                                var hash = createHash(r.x, r.y, r.z)
                                r.hash = hash

                                this.workers.build(str, r).then(function(result) {
                                        if (!result) return
                                        var dt = Date.now()
                                        this.loadedblocks[r.hash] = result.value
                                        this.loadqueuehash[r.hash] = undefined
                                        this.parent.redraw()//updateTiles()
                                }.bind(this))

                                this.currentRequest = undefined
                                this.cleanLoadedBlocks()
                                this.updateLoadQueue()
                        }
                }

                // returns a block by hash
                this.getBlockByHash = function(hash) {
                        return this.loadedblocks[hash]
                }

                // Check if there are tiles in the queue and loads the next one via RPC
                this.updateLoadQueue = function() {

                        if (this.currentRequest) return; // already loading something...
                        if (this.loadqueue.length > 0) {

                                var zscalar = 1280

                                // sort queue on distance to cursor
                                for (var i = 0; i < this.loadqueue.length; i ++) {
                                        var q = this.loadqueue[i]
                                        var dx = this.centers[q.z][0] - q.x
                                        var dy = this.centers[q.z][1] - q.y

                                        var dz = (20-q.z) * zscalar
                                        q.dist = (dx * dx + dy * dy) * (50000 - dz)
                                }

                                this.loadqueue = this.loadqueue.sort(function(a,b) {
                                        if (a.dist > b.dist) return -1
                                        if (a.dist < b.dist) return 1
                                        return 0
                                })

                                var R =        this.currentRequest = this.loadqueue.pop()
                                this.rpc.urlfetch.grabmap(R.x, R.y, R.z).then(function(result) {
                                        this.loadstring(result.value)
                                }.bind(this))

                                // take closest one from the queue
                        }
                }

                this.destroy = function() {
                        this.clearInterval(this.theinterval)
                }

                // looks up a city by latlong in city dictionary
                this.gotoCity = function(name, zoom, time) {
                        if (!name || name.length == 0) return
                        var n2 = name.toLowerCase().replace(' ', '')

                        var c = this.cities[n2]
                        if (c) {
                                this.setCenterLatLng(c[1], c[0], zoom,time)
                        } else {
                                console.log('city not found: ', name)
                        }
                }

                this.init = function(prev) {
                        this.centers = []

                        this.workers = prev && prev.workers || worker(0)
                        // lookup table of cities
                        this.cities = {
                                manhattan: [40.7072121, -74.0067985],
                                amsterdam: [52.3608307,   4.8626387],
                                sanfrancisco: [37.6509102, -122.4889338],
                                sanfrancisco_goldengatepark: [37.7677892, -122.4853213],
                                seoul: [37.5275421, 126.9748078],
                                seoel: [37.5275421, 126.9748078],
                                shenzhen_hqb: [22.5402897, 114.0846914],
                                hongkong: [22.2854084, 114.1600463],
                                sydney: [-33.8466226, 151.2277997],
                                london: [51.5091502, -0.1471011],
                                texel: [53.0731212,4.712878]
                        }

                        this.gotoCity('manhattan', 13)

                        // interval to poll the loadqueue
                        //!TODO maybe remove
                        this.theinterval = this.setInterval(function() {
                                this.updateLoadQueue()
                        }.bind(this), 100)

                        this.rpc.urlfetch.sessionstart()
                        //this.setCenter(33656/2,21534/2, 16)
                }
        })

        // Every time we re-draw process the
        this.atAnimate = function() {
                this.updateTiles()
        }

        // make a new dataset and updatetiles
        this.oninit = function() {
                this.dataset = this.mapdataset({name: 'mapdata'})
                //!TODO odd redraw might miss? please remove
                this.setInterval(this.updateTiles, 1000)
        }

        // Unproject camera to XYZ (see GLU Unproject)
        function UnProject(glx, gly, glz, modelview, projection) {
                var inv = vec4()
                var A = mat4.mat4_mul_mat4(modelview, projection)
                var m = mat4.invert(A)
                inv[0] = glx
                inv[1] = gly
                inv[2] = 2.0 * glz - 1.0
                inv[3] = 1.0
                out = vec4.vec4_mul_mat4(inv, m)
                // divide by W to perform perspective!
                out[0] /= out[3]
                out[1] /= out[3]
                out[2] /= out[3]
                return vec3(out)
        }

        // Project a mousecoord to map plane decoding (in, mouse, out, GL units)
        this.projectonplane = function(coord) {
                var vp = this.find('mapinside')
                if (!vp) return

                var sx = vp.layout.width
                var sy = vp.layout.height

                var mx = (coord[0] / (sx / 2)) - 1.0
                var my =  (coord[1] / (sy / 2)) - 1.0

                var view = vp.colormatrices.lookatmatrix
                var invview = mat4.identity()
                mat4.invert(view, invview)

                var aspect = vp.layout.width/vp.layout.height
                var nearheight = Math.tan((vp.fov/2) * ((Math.PI * 2)/360.0)) * vp.nearplane
                var nearwidth = nearheight * aspect
                var zeropos = vec4(0, 0, 0, 1.0)
                var camerainview = vec4(mx * nearwidth,my * nearheight, -vp.nearplane, 0.0)
                var zeroworld = vec4.mul_mat4(zeropos, invview)
                var cameraworld = vec4.mul_mat4(camerainview, invview)
                var end = vec3(zeroworld[0] + cameraworld[0] * 1000, zeroworld[1] + cameraworld[1] * 1000, zeroworld[2] + cameraworld[2] * 1000)

                var R = vec3.intersectplane(zeroworld, end, vec3(0, 1, 0), 0)
                if (!R) return null

                var M = this.find('MARKER')
                if (M) {
                        M.pos = vec3(R[0],R[1]-M.fontsize,R[2])
                        M.text =(Math.round(M.pos[0] * 100)/100) + ', ' +  (Math.round(M.pos[2] * 100)/100)
                }
                return R
        }

        // debug tile counter
        var alltiles = 0

        // All tiles use tilebasemixin
        var tilebasemixin = define.class(Object, function() {

                this.drawtarget = 'color'

                this.attributes = {
                        // the translate in integer units
                        trans: vec2(0),
                        // the coordinate in integer units
                        coord: vec2(0),
                        // center coordinate in mercatormeters
                        centerpos: vec2(4,3),
                        // zoomlevel of the tile
                        zoomlevel: 16,
                        // animation for bufferloaded
                        bufferloaded: 0.0,

                        //tiletrans: vec2(0),
                        // fog color
                        fog: vec4('lightblue'),
                        // fog start
                        fogstart: 14000.0,
                        // fog end
                        fogend: 24000.,
                        // how many zoom levels away from basezoom
                        layeroffset: 0,
                        // thickness of the layer
                        layerzmult: 0,
                        // layer z offset
                        layerzoff: 0,
                        // how far inbetween two zoomlevels you are
                        fraczoom: 0.5,
                        // center in mercatormeters
                        centermeter: vec2(0),
                        // how many meters a tile spans
                        meterspertile: 1
                }
                // amount of frames it has waited since it got queued in the load
                this.frameswaited = 0
                // not animated bufferloaded as boolean
                this.bufferloadbool = false

                this.lastpos = vec2(0)

                // return the tile position
                this.calctilepos = function() {
                        var x = Math.floor(this._coord[0] + this._trans[0])
                        var y = Math.floor(this._coord[1] + this._trans[1])
                        return [x,y, this._zoomlevel ]
                }

                this.init = function() {
                        var R = this.calctilepos()
                        this.tilename = 'tile' + alltiles.toString() + '_' + this.layeroffset
                        alltiles ++
                        this.lastpos = vec3(R[0], R[1], R[2])
                }

                // sets the position informatio of the tile
                this.setpos = function(newcoord, newzoom, frac, fraczoom, centermeter) {
                        this._tiletrans = frac
                        this._centermeter = centermeter
                        this._zoomlevel = newzoom
                        this._coord = vec2(Math.floor(newcoord.x), Math.floor(newcoord.y))
                        this._fraczoom = fraczoom
                        this.checknewpos()
                }

                // calculate if the position changed since the last frame, used for tile buffer recycling
                // see if it should have a new vertexbuffer compared to last frame
                this.checknewpos = function(thetime) {
                        var R = this.calctilepos()
                        var newpos =         vec3(R[0], R[1], R[2])
                        if (this.lastpos[0] != newpos[0] || this.lastpos[1] != newpos[1] || this.lastpos[2] != newpos[2]) {
                                this.lastpos = newpos
                                this.tilehash = createHash(this.lastpos[0], this.lastpos[1], this.lastpos[2])
                                this.bufferloaded = 0
                                this.frameswaited = 0
                                this.bufferloadbool = false
                                this.queued  = 0
                                this.redraw()
                                this.loadbuffer(thetime)
                        }else {
                                if (this.bufferloadbool == false) this.loadbuffer(thetime);else this.bl.lasttime = thetime
                        }
                }

                // loads the tile buffer, wraps around loadBufferFromTile
                // called in updateTiles
                this.loadbuffer = function() {
                        md = this.mapdata
                        if (md) {
                                this.bl = md.getBlockByHash(this.tilehash)
                                if (this.bl) {
                                        if (this.loadBufferFromTile(this.bl)) {

                                                if (this.frameswaited == 0) {
                                                        this.bufferloaded = 1.0
                                                } else {
                                                        this.bufferloaded = Animate({1: {value: 1.0, motion: 'inoutquad'}})
                                                }
                                                this.bufferloadbool = true

                                                var trans = this.bl.transform.translate
                                                var mercmeter = geo.latLngToMeters(trans[0], trans[1])
                                                this.centerpos =vec2(mercmeter[0], mercmeter[1])
                                                this.redraw()
                                        }
                                }
                                else {
                                        this.frameswaited ++
                                        if (this.queued == 0) {
                                                if (this.shaders && this.shaders.hardrect && this.shaders.hardrect.update) this.shaders.hardrect.update()
                                                if (this.resetbuffer) this.resetbuffer()
                                                md.addToQueue(this.lastpos[0], this.lastpos[1], this.lastpos[2])
                                                this.queued  = 1
                                        }
                                }
                        }
                }

                this.tilesize = BufferGen.TileSize
                this.width = this.tilesize
                this.height = this.tilesize
        })

        // view implementation of the building
        define.class(this, 'buildingtile', '$ui/view', function() {
                this.is = tilebasemixin
                this.loadBufferFromTile = function(tile) {
                        if (!this.shaders || !this.shaders.hardrect || !tile.buildingVertexBuffer) return false
                        this.shaders.hardrect.mesh = tile.buildingVertexBuffer
                        this.shaders.hardrect.mesh.sticky = true

                        return true
                }

                this.hardrect = function() {

                        this.position = function() {
                                //idxpos = (view.trans.xy * vec2(1, -1)) * vec2(1, -1)
                                pos = vec2(1, -1) * mesh.pos.xy;// + (idxpos - view.tiletrans) * view.tilesize
                                pos.xy -= ((((view.centerpos- view.centermeter)) / view.meterspertile) * 1024.0) * vec2(-1.0, 1.0)
                                pos.xy /= pow(2.0, view.layeroffset - view.fraczoom -2)
                                //pos.xy *= view.meterspertile/view.tilesize

                                respos = vec4(pos.x, -((mesh.pos.z * 1024.)/(view.meterspertile / pow(2.0, view.fraczoom))) * view.bufferloaded + view.layeroffset * view.layerzmult + view.layerzoff, pos.y, 1) * view.totalmatrix * view.viewmatrix
                                //r.w += 0.002
                                return respos
                        }

                        this.mesh =  BufferGen.BuildingVertexStruct.array()

                        this.update = function() {
                                this.mesh =  BufferGen.BuildingVertexStruct.array()
                        }

                        this.drawtype = this.TRIANGLES

                        this.color = function() {
                                var noise = noise.cheapnoise(pos * 0.02) * 0.1 + 0.5
                                var prefog = mesh.color1
                                prefog.xyz *= 0.6 + 0.4 * max(0.0, min(1.0, ((mesh.pos.z - mesh.height) * 0.001) + 0.4))
                                var zdist = max(0.,min(1.,(respos.z-view.fogstart)/view.fogend))
                                //zdist *= zdist
                                return mix(prefog, view.fog, zdist)
                        }
                }
        })

        // view implementation of the land
        define.class(this, 'landtile', '$ui/view', function() {

                this.is = tilebasemixin

                this.loadBufferFromTile = function(tile) {
                        if (!this.shaders || !this.shaders.hardrect || !tile.landVertexBuffer) return false
                        this.shaders.hardrect.mesh = tile.landVertexBuffer
                        this.shaders.hardrect.mesh.sticky = true

                        return true
                }
                this.pickalpha  = 0.1
                this.hardrect = function() {
                        this.texture = require('./mapmaterial.png')
                        this.position = function() {
                                idxpos = (view.trans.xy * vec2(1, -1)) * vec2(1, -1)
                                pos = vec2(1, -1) * mesh.pos.xy;
                                pos.xy -= ((((view.centerpos- view.centermeter)) / view.meterspertile) * 1024.0) * vec2(-1.0, 1.0)
                                pos.xy /= pow(2.0, view.layeroffset - view.fraczoom -2)
                                respos = vec4(pos.x, view.layeroffset * view.layerzmult + view.layerzoff, pos.y, 1) * view.totalmatrix * view.viewmatrix
                                return respos
                        }

                        this.mesh =  BufferGen.LandVertexStruct.array()

                        this.update = function() {
                                this.mesh =  BufferGen.LandVertexStruct.array()
                                var a = BufferGen.TileSize * 0.05
                                var b = BufferGen.TileSize - a
                                var col =  vec4(0, 0, 1, 0.2)
                        }

                        this.drawtype = this.TRIANGLES
                        this.depth_test = 'disabled'

                        this.color = function() {
                                PickGuid = mesh.pos.z
                                var noise = noise.cheapnoise(pos * 0.02) * 0.07 + 0.5
                                var texcol = mesh.color1
                                var prefog = texcol
                                var zdist = max(0.,min(1.,(respos.z-view.fogstart)/view.fogend))
                                zdist *= zdist
                                return mix(prefog, view.fog, zdist)
                        }
                }
        })

        // view implementation of the label tile
        define.class(this, 'labeltile', '$ui/labelset', function() {
                //this.polygonoffset = 100.0
                this.is = tilebasemixin
                this.fgcolor = 'black'
                this.font = ubuntufont

                this.textpositionfn = function(pos, tag) {
                //        idxpos = (this.trans.xy * vec2(1, -1)) * vec2(1, -1)
                }

                this.textstyle = function(style, tag) {
                        var pos = style.pos
                        var rpos = vec2(1, -1) * pos.xz
                        rpos.y += pos.y
                        rpos.xy -= ((((this.centerpos- this.centermeter)) / this.meterspertile) * 1024.0) * vec2(-1.0, 1.0)
                        rpos.xy /= pow(2.0, this.layeroffset - this.fraczoom - 2)
                        style.pos = vec3(rpos.x, -25 + this.layeroffset * this.layerzmult + this.layerzoff, rpos.y)
                        style.fgcolor = 'black'
                        // style.outlinecolor = 'white'
                        // style.outlinethickness = 1.0
                        // style.outline = true
                        return style
                }

                this.resetbuffer = function() {
                        this.labels = []
                }

                this.loadBufferFromTile = function(tile) {
                        var LabelSource = tile.Labels

                        if (!LabelSource) {
                                this.labels = []
                                return
                        }
                        var thelabels = []
                        var rankfontsizes = {
                                0: 60,
                                1: 55,
                                2: 50,
                                3: 45,
                                4: 40,
                                5: -1,
                                6: -1,
                                7: -1
                        }

                        for (var i = 0; i < LabelSource.length; i ++) {
                                var l = LabelSource[i]
                                var f = 30
                                if (l.scalerank !== undefined) {
                                        f = rankfontsizes[l.scalerank] * Math.pow(2, this.layeroffset - 1)
                                }

                                if (f > -1) {
                                        var l2 = {text: l.name, fontsize: f,outline: false, color: vec4('white'), outlinecolor: vec4('black'), pos: vec3(l.x, -11,l.y)}
                                        thelabels.push(l2)
                                }
                        }
                        this.labels = thelabels
                        return true
                }

                this.typeface = function() {
                        this.depth_test = 'src_depth <= dst_depth'
                }
                //this.depth_test = 'enabled'

                this.position = 'absolute'
                this.bgcolor = NaN
                this.align = 'center'
                this.render = function() {}
        })

        // view class of the roadtile
        define.class(this, 'roadtile', '$ui/view', function() {
                this.is = tilebasemixin
                this.loadBufferFromTile = function(tile) {
                        if (!this.shaders || !this.shaders.hardrect || !tile.roadVertexBuffer) return
                        this.shaders.hardrect.mesh = tile.roadVertexBuffer
                        this.shaders.hardrect.mesh.sticky = true
                        return true
                }

                this.hardrect = function() {
                        this.texture = require('./mapmaterial.png')
                        this.position = function() {
                                var sidevec = mesh.pos.zw
                                var side = mesh.geom.x
                                var dist = mesh.geom.y
                                var linewidth = mesh.geom.z
                                var possrc = mesh.pos.xy + sidevec * side * linewidth * 0.5
                                var pos = vec2(1, -1) * possrc.xy;// + (idxpos - view.tiletrans) * view.tilesize

                                pos.xy -= ((((view.centerpos- view.centermeter)) / view.meterspertile) * 1024.0) * vec2(-1.0, 1.0)
                                pos.xy /= pow(2.0, view.layeroffset - view.fraczoom -2)
                                respos = vec4(pos.x, view.layeroffset * view.layerzmult + view.layerzoff, pos.y, 1) * view.totalmatrix * view.viewmatrix
                                respos.w += mesh.pos.z * 0.1
                                return respos
                        }

                        this.vertexstruct = BufferGen.RoadVertexStruct

                        this.mesh =  this.vertexstruct.array()

                        this.update = function() {
                                this.mesh =  this.vertexstruct.array()
                                /* var a = TileSize / 4
                                var b = TileSize - a
                                this.mesh.push(a,a)
                                this.mesh.push(b,a)
                                this.mesh.push(b,b)
                                this.mesh.push(a,a)
                                this.mesh.push(b,b)
                                this.mesh.push(a,b); */
                        }

                        this.drawtype = this.TRIANGLES
                        this.depth_test = 'disabled'

                        this.color = function() {
                                var texcol = mesh.color;
                                var prefog = texcol;
                                var zdist = max(0.,min(1.,(respos.z-view.fogstart)/view.fogend))
                                zdist *= zdist
                                return mix(prefog, view.fog, zdist)
                        }
                }

                this.hardrect = true
        })

        this.bgcolor = vec4('#c0c0d0')
        this.flex = 1
        this.clearcolor = 'black'
        this.framessincerender = 0

        this.atDraw = function() {
                this.framessincerender ++
        }

        // update the map tiles
        this.updateTiles = function() {
                if (!this.dataset) return
                if (!this.dataset.centers) return
                if (!this.dataset.latlong) return

                var sourcezoom = this.dataset.zoomlevel
                this.zoomlevel = Math.ceil(sourcezoom)
                this.fraczoom = sourcezoom - this.zoomlevel
                this.meters_per_pixel = geo.metersPerPixel(this.zoomlevel)

                // Center of viewport in meters, and tile
                this.center_meters = geo.latLngToMeters(this.dataset.latlong[0], this.dataset.latlong[1])

                this.center_tile = []
                var frac = []

                for (var i = 0; i < 3; i ++) {
                        frac.push(vec2(0, 0))
                        this.center_tile.push(geo.tileForMeters(this.center_meters[0], this.center_meters[1], this.zoomlevel + i))
                }

                for (var a = 0; a < this.tilestoupdate.length; a ++) {
                        var rt = this.tilestoupdate[a]
                        rt.meterspertile = geo.metersPerTile(this.zoomlevel + rt._layeroffset)
                        rt.setpos(this.center_tile[rt.layeroffset], this.zoomlevel + rt._layeroffset, frac[rt._layeroffset], this.fraczoom, this.center_meters)
                        rt.redraw()
                }
        }

        this.dumpdebug = function() {
                for (var a = 0; a < this.tilestoupdate.length; a ++) {
                        var rt = this.tilestoupdate[a]
                        console.log(rt.lastpos)
                }
        }

        this.layout = function(){
                this.dotwice = 0
                if (this.rerender) this.rerender()
        }

        this.render = function() {
                var layout = this._layout
                this.tilestoupdate = []

                var res = [this.dataset]
                var res3d = []
                var buildings3d = []
                var labels3d = []
                var poi3d = []
                var div = 512
                this.tilewidth = Math.ceil(layout.width / div)
                this.tileheight = Math.ceil(layout.height / div)

                this.camdist = 20000;

                var aspect = layout.width / layout.height
                var fov = (Math.atan(((layout.width / 2) * 40) / this.camdist) * 360 / 6.283) / aspect

                var basew = this.tilewidth / 2
                var baseh = this.tileheight / 2
                var showland = true

                for (var layer = 0; layer < 2; layer ++) {
                        this.tilewidth = 0;
                        this.tileheight = 0;
                        var tilearea = vec2(this.tilewidth, this.tileheight)
                        var ltx = 0
                        var lty = 0
                        var extw = basew * Math.pow(2.0, layer - 0.5)
                        var exth = baseh * Math.pow(2.0, layer - 0.5)
                        xs = -extw
                        xe = -xs + 1
                        ys = -exth
                        ye = -ys + 1
                        if (showland) {
                                for (var x = xs; x < xe; x ++) {
                                        for (var y = ys; y < ye; y ++) {
                                                var land = this.landtile({host: this, mapdata: this.dataset, fog: this.bgcolor, tilearea: tilearea, trans: vec2(x,y), layeroffset: layer})
                                                this.tilestoupdate.push(land)
                                                res3d.push(land)
                                        }
                                }
                        }

                        for (var x = xs; x < xe; x ++) {
                                for (var y = ys; y < ye; y ++) {
                                        var road = this.roadtile({host: this, mapdata: this.dataset, fog: this.bgcolor, tilearea: tilearea, trans: vec2(x,y), layeroffset: layer})
                                        this.tilestoupdate.push(road)
                                        res3d.push(road)
                                }
                        }

                        for (var x = xs; x < xe; x ++) {
                                for (var y = ys; y < ye; y ++) {
                                        var building = this.buildingtile({host: this, mapdata: this.dataset, fog: this.bgcolor, tilearea: tilearea, trans: vec2(x,y), layeroffset: layer})
                                        this.tilestoupdate.push(building)
                                        buildings3d.push(building)
                                }
                        }

                        if (layer == 1 && this.showlabels) {
                                for (var x = xs; x < xe; x ++) {
                                        for (var y = ys; y < ye; y ++) {
                                                var labels = this.labeltile({host: this, mapdata: this.dataset, fog: this.bgcolor, tilearea: tilearea, trans: vec2(x,y), layeroffset: layer})
                                                this.tilestoupdate.push(labels)
                                                labels3d.push(labels)
                                        }
                                }
                        }
                }

                var zoom = 0.25

                res.push(
                        view({
                                bgcolor: 'red',
                                flex: 1,
                                viewport: '3d',
                                name: 'mapinside',
                                nearplane: 100 ,
                                fov: fov,
                                farplane: this.camdist * 2,
                                camera: vec3(0, -this.camdist * zoom * 0.13, this.camdist * zoom * 0.3),
                                fov: fov,
                                up: vec3(0, 1, 0),
                                lookat: vec3(0, 0, 0)
                        },[
                                view({
                                        bgcolor: NaN
                                },[
                                        res3d,
                                        buildings3d,
                                        labels3d,
                                        this.constructor_children
                                ])
                        ])
                )
                //res.push(this.constructor_children)
                var camdist = this.camdist
                res.push(button({
                        position: 'absolute',
                        top: 20,
                        label: '2D/3D',
                        mode: 1,
                        click: function() {
                                var map = this.find('mapinside')
                                if (this.mode == 1) {
                                        this.mode = 2
                                        map.camera = Animate({1: vec3(0, -4650, 150)})
                                }
                                else {
                                        this.mode = 1
                                        map.camera = Animate({1: vec3(0, -camdist * zoom * 0.13,camdist * zoom * 0.3)})
                                }

                        }
                }))
                res.push(label({
                        bottom: 10,
                        fontsize: 8,
                        position: 'absolute',
                        fgcolor: 'black',
                        text: 'Vector data copyright OpenStreetMap contributors, Whos On First. Webservice by mapzen.',
                        font: ubuntufont
                }))
                this.framessincerender = 0

                if(!this.dotwice && this.rerender) this.dotwice++, this.rerender()

                return res
        }

        this.atChildrenRendered = function() {
                this.updateTiles()
                this.redraw()
        }

})


text:
/*!
 *
 * The Store Registry is used to keep organized in one place all the AJAX
 * requests our app could make.
 * Each entry in the registry could be a single call, or a combination of
 * multiple chainable calls.
 *
 * TODO:
 *  - Data aggregation in combo entries. (to be supported by store.es6)
 *
 *
 * ENTRY OPTIONS:
 *   url: a fully qualified uri
 *   headers: http headers (default: {})
 *   data: JSON object descriptive of the data to be sent
 *   type: a string enum. html, xml, json, or jsonp
 *   contentType: sets the Content-Type of the request. Eg: application/json
 *   crossOrigin: for cross-origin requests for browsers that support it
 *   jsonpCallback: Specify the callback function name for a JSONP request
 *
 * COMBO RELATED OPTIONS:
 *   id: identifier of a previously defined registry entry
 *   map: object used to define mapping relation between the current entry data
 *     and the previous one.
 *
 * COMBO EXAMPLE:
 *   'combo': [{
 *     'url': '/api/first',
 *   }, {
 *     'url': '/api/second',
 *     'data': {
 *       'default': 'stuff'
 *     },
 *     'map': {
 *       'deeply.nested.key': 'extra'
 *     }
 *   }]
 *
 *   assuming that a call to '/api/first' produces a json like:
 *   {
 *     deeply: {
 *       nested: {
 *         key: 'extraInfo'
 *       }
 *     }
 *   }
 *
 *   the value of the json.deeply.nested.key will be passed to the key
 *   'extra' of the data object for the call to '/api/second'.
 *
 */

var base = '/api';

export var registry = {

  'one': {
    'url': `${base}/one`
  },

  'two': {
    'url': `${base}/testing`,
    'data': {
      'defaultKey': 'itWillRemain'
    }
  },

  'combo': [{
    'id': 'one'
  }, {
    'id': 'two',
    'map': {
      'greetings': 'extraData'
    }
  }, {
    'url': `${base}/last`,
    'data': {
      'default': 'stuff'
    },
    'map': {
      'deeply.nested.key': 'extra'
    }
  }],

  'booking-data': {
    'url': `${base}/booking-data`
  }

};


text:
<!DOCTYPE HTML>

<html>
<head>
	<title>{name}</title>
	<script type="text/javascript" src="../closure/closure/goog/base.js"></script>
	<script type="text/javascript" src="{name}.js"></script>
</head>

<body onload="{name}.start()"></body>

</html>


text:
package com.example.android.miwok;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import java.util.ArrayList;

public class PhrasesActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.word_list);

        ArrayList<Word> words = new ArrayList<Word>();

        words.add(new Word("Where are you going?","minto wuksus"));
        words.add(new Word("What is your name?","tinnә oyaase'nә"));
        words.add(new Word("My name is...","oyaaset..."));
        words.add(new Word("How are you feeling?","michәksәs?"));
        words.add(new Word("I'm feeling good.","kuchi achit"));
        words.add(new Word("Are you coming?","әәnәs'aa?"));
        words.add(new Word("Yes, I'm coming.","hәә' әәnәm"));
        words.add(new Word("I'm coming.","әәnәm"));
        words.add(new Word("Let's go.","yoowutis"));
        words.add(new Word("Come here.","әnni'nem"));

        WordAdapter itemsAdapter = new WordAdapter(this, words,R.color.category_phrases);
        ListView listView = (ListView) findViewById(R.id.list);
        if(listView != null)
            listView.setAdapter(itemsAdapter);
    }
}


text:
<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'NXpMoQbj9pEXuBkd79DZJwptmv4biEQg',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        /*'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],*/
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
            'loginUrl' => ['site/index'],
            'returnUrl' => ['search/index']
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['info'],
                    'categories' => ['marks'],
                    'logFile' => '@app/runtime/logs/marks.log',
                ],
            ],
        ],
        'authClientCollection' => require(__DIR__ . '/clients.php'),
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = 'yii\gii\Module';
}

return $config;


text:
<?php

// Based on Scuttle API classes
// Implements the del.icio.us API request for a user's posts, optionally filtered by tag and/or
// date. Note that when using a date to select the posts returned, del.icio.us uses GMT dates --
// so we do too.

// del.icio.us behavior:
// - includes an empty tag attribute on the root element when it hasn't been specified

// Scuttle behavior:
// - Uses today, instead of the last bookmarked date, if no date is specified

// GetBoo behavior:
// - support multiple tags, separated by a space or plus (+) sign

// Force HTTP authentication first!
require_once('httpauth.inc.php');

// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
{
	$tag = trim($_REQUEST['tag']);
	$tagNames = explode(' ', trim($tag));

	$tagcount = count($tagNames);
	for ($i = 0; $i < $tagcount; $i ++)
	{
		$tagNames[$i] = trim($tagNames[$i]);
	}
}
else
    $tagNames = NULL;

// Check to see if a date was specified; the format should be YYYY-MM-DD
if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != ""))
    $dtstart = trim($_REQUEST['dt']);
else
    $dtstart = date('Y-m-d H:i:s');
$dtend = date('Y-m-d H:i:s', strtotime($dtstart .'+1 day'));

// Filter by URL
if (isset($_REQUEST['url']) && strlen($_REQUEST['url']) > 0) {
    $hash = ($_REQUEST['url']);
} else {
    $hash = NULL;
}

// Get the posts relevant to the passed-in variables.
include("../includes/tags_functions.php");
require_once("../includes/protection.php");
$user = new User();
$userName = $user->getUsername();
if($tagNames)
	$bookmarks = getTagsBookmarks($tagNames, 0, MAX_API_BOOKMARKS, $userName, "../", $dtstart, $dtend, $hash);
else
	$bookmarks = getUserBookmarks($userName, 0, MAX_API_BOOKMARKS, "../", $dtstart, $dtend, $hash);

// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<posts'. (is_null($dtstart) ? '' : ' dt="'. $dtstart .'"') .' tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($userName, 'xml') ."\">\r\n";

foreach($bookmarks as $row) {
    if (is_null($row['description']) || (trim($row['description']) == ''))
        $description = '';
    else
        $description = 'extended="'. filter($row['description'], 'xml') .'" ';

    $taglist = returnAllTags($row['id'], "../");

    echo "\t<post href=\"". filter($row['url'], 'xml') .'" description="'. filter($row['title'], 'xml') .'" '. $description .'hash="'. md5($row['url']) .'" tag="'. filter($taglist, 'xml') .'" time="'. date('Y-m-d\TH:i:s\Z', strtotime($row['ADD_DATE'])) ."\" />\r\n";
}

echo '</posts>';
?>


text:
<?php

/**
* getLookupMainTableSettings - tests whether the lookup link exists between the tables
*
*  returns array with ProjectSettings class for main table if the link exists in project settings.
*  returns NULL otherwise
*/
function getLookupMainTableSettings($lookupTable, $mainTableShortName, $mainField, $desiredPage = "")
{
	global $lookupTableLinks;
	if(!isset($lookupTableLinks[$lookupTable]))
		return null;
	if(!isset($lookupTableLinks[$lookupTable][$mainTableShortName.".".$mainField]))
		return null;
	$arr = &$lookupTableLinks[$lookupTable][$mainTableShortName.".".$mainField];
	$effectivePage = $desiredPage;
	if(!isset($arr[$effectivePage]))
	{
		$effectivePage = PAGE_EDIT;
		if(!isset($arr[$effectivePage]))
		{
			if($desiredPage == "" && 0 < count($arr))
			{
				$effectivePage = $arr[0];
			}
			else
				return null;
		}
	}
	return new ProjectSettings($arr[$effectivePage]["table"], $effectivePage);
}

/**
* $lookupTableLinks array stores all lookup links between tables in the project
*/
function InitLookupLinks()
{
	global $lookupTableLinks;

	$lookupTableLinks = array();

	$lookupTableLinks["waste"]["customerwaste.WasteId"]["edit"] = array("table" => "customerwaste", "field" => "WasteId", "page" => "edit");
	$lookupTableLinks["waste"]["customerwastebyday.WasteId"]["edit"] = array("table" => "customerwastebyday", "field" => "WasteId", "page" => "edit");
	$lookupTableLinks["waste"]["customerwastebymonth.WasteId"]["edit"] = array("table" => "customerwastebymonth", "field" => "WasteId", "page" => "edit");
	$lookupTableLinks["waste"]["customerwastebyweek.WasteId"]["edit"] = array("table" => "customerwastebyweek", "field" => "WasteId", "page" => "edit");
	$lookupTableLinks["waste"]["customerwastebyyear.WasteId"]["edit"] = array("table" => "customerwastebyyear", "field" => "WasteId", "page" => "edit");
	$lookupTableLinks["RegisterPage_customer"]["user.CustomerId"]["edit"] = array("table" => "user", "field" => "CustomerId", "page" => "edit");
	$lookupTableLinks["customer"]["admin_users.CustomerId"]["edit"] = array("table" => "admin_users", "field" => "CustomerId", "page" => "edit");
}

?>


text:
THIS REPOSITORY WAS MOVED!
See https://github.com/symentis/grails-audit-logging-plugin/


text:
class ChaseServersController < ApplicationController
  before_action :set_chase_server, only: [:show, :edit, :update, :destroy]

  # GET /chase_servers
  # GET /chase_servers.json
  def index
    @chase_servers = ChaseServer.all
  end

  # GET /chase_servers/1
  # GET /chase_servers/1.json
  def show
  end

  # GET /chase_servers/new
  def new
    @chase_server = ChaseServer.new
  end

  # GET /chase_servers/1/edit
  def edit
  end

  # POST /chase_servers
  # POST /chase_servers.json
  def create
    @chase_server = ChaseServer.new(chase_server_params)

    respond_to do |format|
      if @chase_server.save
        format.html { redirect_to @chase_server, notice: 'Chase server was successfully created.' }
        format.json { render action: 'show', status: :created, location: @chase_server }
      else
        format.html { render action: 'new' }
        format.json { render json: @chase_server.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /chase_servers/1
  # PATCH/PUT /chase_servers/1.json
  def update
    respond_to do |format|
      if @chase_server.set(chase_server_params)
        format.html { redirect_to @chase_server, notice: 'Chase server was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: 'edit' }
        format.json { render json: @chase_server.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /chase_servers/1
  # DELETE /chase_servers/1.json
  def destroy
    @chase_server.destroy
    respond_to do |format|
      format.html { redirect_to chase_servers_url }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_chase_server
      @chase_server = ChaseServer.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def chase_server_params
      params.require(:chase_server).permit(:hostname, :make, :model, :serial_no, :sw_version, :location_device_id, :beacon_receiver_ids, :router_id, :persistent)
    end
end


text:
from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations
from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations

from ._patch import __all__ as _patch_all
from ._patch import *  # type: ignore # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk

__all__ = [
    "GuestDiagnosticsSettingsAssociationOperations",
    "GuestDiagnosticsSettingsOperations",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()


text:
package com.intellij.cvsSupport2.actions;

import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
import com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.DeleteTagDialog;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.actions.VcsContext;

import java.util.Arrays;
import java.util.Collection;

/**
 * author: lesya
 */
public class DeleteTagAction extends ActionOnSelectedElement{

  public DeleteTagAction() {
    super(false);
    CvsActionVisibility visibility = getVisibility();
    visibility.canBePerformedOnSeveralFiles();
    visibility.addCondition(FILES_EXIST_IN_CVS);
  }

  protected String getTitle(VcsContext context) {
    return com.intellij.CvsBundle.message("action.name.delete.tag");
  }

  protected CvsHandler getCvsHandler(CvsContext context) {
    DeleteTagDialog deleteTagDialog = new DeleteTagDialog(collectFiles(context),
                                                          context.getProject());
    deleteTagDialog.show();
    if (!deleteTagDialog.isOK())
      return CvsHandler.NULL;
    return CommandCvsHandler.createRemoveTagAction(context.getSelectedFiles(),
        deleteTagDialog.getTagName());
  }

  private Collection<FilePath> collectFiles(VcsContext context) {
    return Arrays.asList(context.getSelectedFilePaths());
  }

}


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
     Use of this source code is governed by a BSD-style license that can be
     found in the LICENSE file. -->

<resources>
    <drawable name="ic_more_vert_24dp">@drawable/ic_more_vert_24dp_on_light_bg</drawable>
    <drawable name="tile_view_icon_background_modern">@drawable/oval_surface_1</drawable>
</resources>


text:
import * as Types from '../actions/Types'

export const auth = (state = {
  loading: false
}, action) => {
  switch(action.type) {
    case Types.ACCOUNT_KIT_AUTH_REQUEST: {
      return Object.assign({}, state, {
        loading: true
      })
    }
    case Types.ACCOUNT_KIT_AUTH_REQUEST_SUCCESS: {
      return Object.assign({}, state, {
        loading: false,
        user: action.user
      })
    }
    case Types.ACCOUNT_KIT_AUTH_REQUEST_FAILURE: {
      return Object.assign({}, state, {
        loading: false,
        error: action.error
      })
    }
    case Types.CHECK_AUTH_COOKIE: {
      return Object.assign({}, state, {})
    }
    case Types.CHECK_AUTH_COOKIE_SUCCESS: {
      return Object.assign({}, state, {
        cookie: action.cookie
      })
    }
    case Types.CHECK_AUTH_COOKIE_FAILURE: {
      return Object.assign({}, state, {
        cookie: false
      })
    }
    case Types.SAVE_AUTH_COOKIE: {
      return Object.assign({}, state, {
        cookie: action.cookie
      })
    }
    case Types.CURRENT_USER_REQUEST: {
      return Object.assign({}, state, {
        loading: true,
        access_token: action.access_token
      })
    }
    case Types.CURRENT_USER_REQUEST_SUCCESS: {
      return Object.assign({}, state, {
        loading: false,
        user: action.user
      })
    }
    case Types.CURRENT_USER_REQUEST_FAILURE: {
      return Object.assign({}, state, {
        loading: false,
        error: action.error
      })
    }
    case Types.LOGOUT_REQUEST: {
      return Object.assign({}, state, {
        user: undefined,
        cookie: undefined
      })
    }
    default:
      return state;
  }
}


text:
ir = 0
rw = data_train_TFIDF.getrow(ir)
print("Liste des tokens racinisé de la première ligne : " + train_array[0])
pd.DataFrame([(ind, vocabulary[ind], vec.idf_[ind], w/vec.idf_[ind], w)  for w,ind in zip(rw.data,rw.indices)], columns=["indices","token","idf","tf","weight"])