Skip to content

Commit 4e19638

Browse files
Merge pull request #149 from labordep/dev-projections
Better tiles render and webmercator projection
2 parents cb0ac83 + 8ee3b23 commit 4e19638

16 files changed

+1621
-257
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"
2+
I am a bench class to test performances
3+
"
4+
Class {
5+
#name : #GeoViewBench,
6+
#superclass : #Object,
7+
#category : #'GeoView-Examples'
8+
}
9+
10+
{ #category : #projections }
11+
GeoViewBench class >> timeToProjectCoordinates [
12+
"Transform coordinates is several projections and return the result is an array"
13+
14+
<script>
15+
| absoluteCoordinatesList projections results |
16+
absoluteCoordinatesList := (1 to: 1000000) collect: [ :i |
17+
AbsoluteCoordinates random ].
18+
projections := {
19+
GeoViewMercatorProjection new.
20+
GeoViewWebMercatorProjection new.
21+
GeoViewUTMProjection new }.
22+
results := Dictionary new.
23+
24+
"project"
25+
projections do: [ :proj |
26+
| time cartesianCoordinatesList |
27+
cartesianCoordinatesList := OrderedCollection new.
28+
"first => projection from lat lon to cart"
29+
time := [
30+
cartesianCoordinatesList :=
31+
(absoluteCoordinatesList collect: [ :coord |
32+
proj projLatLonToCart: coord ]) ] timeToRunWithoutGC.
33+
"second => projection from cart to lat lon"
34+
time := time + [
35+
cartesianCoordinatesList do: [ :coord |
36+
coord ifNotNil:[ proj projCartToLatLon: coord ] ] ] timeToRunWithoutGC.
37+
results at: proj printString put: time ].
38+
39+
"show result"
40+
results inspect
41+
]
42+
43+
{ #category : #'see class side' }
44+
GeoViewBench >> seeClassSide [
45+
]

src/GeoView-Examples/GeoViewExamples.class.st

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,11 @@ GeoViewExamples class >> createTissotIndicatorCircles [
235235

236236
i := 1.
237237
-70 to: 70 by: 15 do:[ :lat |
238-
-180 to: 180 by: 15 do:[ :lon |
238+
-180 to: 180 by: 15 do:[ :lon | | coordinates |
239+
coordinates := ( lat @ lon ) asAbsoluteCoordinates.
239240
circles add: (GeoCircle new key: i;
240-
absoluteCoordinates: ( lat @ lon ) asAbsoluteCoordinates ;
241-
fillStyle: (Color green alpha: 0.5) asSmockFillStyle;
241+
absoluteCoordinates: coordinates ;
242+
fillStyle: (Color green alpha: 0.25) asSmockFillStyle;
242243
strokeStyle: (Color green asSmockStrokeStyle width: 1);
243244
radiusInMeters: radiusInM;
244245
yourself).
@@ -636,19 +637,18 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleHybrid [
636637
{ #category : #'examples - tiles provider' }
637638
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleRoadmap [
638639
"This example show a map layer (assuming an internet connection to default url of google"
639-
640+
640641
| element layer |
641642
element := GeoViewElement new.
642-
643-
element maxScaleInMeters: element maxScaleInMeters * 8.
644-
643+
644+
element maxScale: element maxScale * 8.
645+
645646
"add carto layer"
646647
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
647648
layer tilesProvider beRoadmapType.
648649
element addLayer: layer.
649650

650651
^ self openViewInWindow: element
651-
652652
]
653653

654654
{ #category : #'examples - tiles provider' }
@@ -658,7 +658,7 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleRoadsOnly [
658658
| element layer |
659659
element := GeoViewElement new.
660660

661-
element maxScaleInMeters: element maxScale * 8.
661+
element maxScale: element maxScale * 8.
662662

663663
"add carto layer"
664664
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
@@ -671,54 +671,51 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleRoadsOnly [
671671
{ #category : #'examples - tiles provider' }
672672
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleSatellite [
673673
"This example show a map layer (assuming an internet connection to default url of google"
674-
674+
675675
| element layer |
676676
element := GeoViewElement new.
677-
678-
element maxScaleInMeters: element maxScaleInMeters * 8.
679-
677+
678+
element maxScale: element maxScale * 8.
679+
680680
"add carto layer"
681681
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
682682
element addLayer: layer.
683683

684684
^ self openViewInWindow: element
685-
686685
]
687686

688687
{ #category : #'examples - tiles provider' }
689688
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleTerrain [
690689
"This example show a map layer (assuming an internet connection to default url of google"
691-
690+
692691
| element layer |
693692
element := GeoViewElement new.
694-
695-
element maxScaleInMeters: element maxScaleInMeters * 8.
696-
693+
694+
element maxScale: element maxScale * 8.
695+
697696
"add carto layer"
698697
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
699698
layer tilesProvider beTerrainType.
700699
element addLayer: layer.
701700

702701
^ self openViewInWindow: element
703-
704702
]
705703

706704
{ #category : #'examples - tiles provider' }
707705
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleTerrainOnly [
708706
"This example show a map layer (assuming an internet connection to default url of google"
709-
707+
710708
| element layer |
711709
element := GeoViewElement new.
712-
713-
element maxScaleInMeters: element maxScaleInMeters * 8.
714-
710+
711+
element maxScale: element maxScale * 8.
712+
715713
"add carto layer"
716714
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
717715
layer tilesProvider beTerrainOnlyType.
718716
element addLayer: layer.
719717

720718
^ self openViewInWindow: element
721-
722719
]
723720

724721
{ #category : #'examples - tiles provider' }
@@ -728,7 +725,7 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingLocal [
728725
| element layer |
729726
element := GeoViewElement new.
730727

731-
element maxScaleInMeters: element maxScale * 8.
728+
element maxScale: element maxScale * 8.
732729

733730
"add carto layer"
734731
layer := GeoViewMapTilesLayer newWithLocalDirectory name:
@@ -754,14 +751,29 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingOSM [
754751
^ self openViewInWindow: element
755752
]
756753

754+
{ #category : #'examples - tiles provider' }
755+
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingOSMWithMercatorProjection [
756+
"This example show a map layer (assuming an internet connection to default url open street map"
757+
758+
| element layer |
759+
element := GeoViewElement new.
760+
element maxScale: element maxScale * 8.
761+
762+
"add carto layer"
763+
layer := GeoViewMapTilesLayer new name: 'Tiles Layer'.
764+
element addLayer: layer.
765+
766+
^ self openViewInWindow: element
767+
]
768+
757769
{ #category : #'examples - tiles provider' }
758770
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingOSMWithSmallTileSize [
759771
"This example show a map layer (assuming an internet connection to default url open street map"
760772

761773
| element layer |
762774
element := GeoViewElement new.
763775

764-
element maxScaleInMeters: element maxScale * 8.
776+
element maxScale: element maxScale * 8.
765777

766778
"add carto layer"
767779
layer := GeoViewMapTilesLayer new name: 'Tiles Layer'.
@@ -1113,7 +1125,7 @@ GeoViewExamples class >> exampleTissotIndicatorMercator [
11131125

11141126
| element objects |
11151127
element := GeoViewUtils createGeoViewForGeoObjects.
1116-
element mapProjection: GeoViewMercatorProjection new. "by default"
1128+
element mapProjection: GeoViewMercatorProjection new.
11171129
"laborde: better to have a vectorial map to considere the deformation because tiles are not available for all projections"
11181130

11191131
"create sample datas"
@@ -1133,7 +1145,7 @@ GeoViewExamples class >> exampleTissotIndicatorUTM [
11331145
"warning before opening"
11341146
(UIManager default
11351147
confirm:
1136-
'This Tissot indicator example using a not finalized UTM Projection, it can works but without stability.
1148+
'This Tissot indicator example using a work in progress UTM Projection, it can works but with glitchs and without stability.
11371149
Start ?'
11381150
label: 'GeoView - Work in progress') ifFalse:[ ^ self ].
11391151

@@ -1149,6 +1161,23 @@ GeoViewExamples class >> exampleTissotIndicatorUTM [
11491161

11501162
]
11511163

1164+
{ #category : #'examples - projections' }
1165+
GeoViewExamples class >> exampleTissotIndicatorWebMercator [
1166+
"This example implement the indicator of Tissot (Nicolas August) for a projection, this indicator indicate the level of deformation of the selection projection"
1167+
1168+
| element objects |
1169+
element := GeoViewUtils createGeoViewForGeoObjects.
1170+
"element mapProjection: GeoViewWebMercatorProjection new." "by default"
1171+
"laborde: better to have a vectorial map to considere the deformation because tiles are not available for all projections"
1172+
1173+
"create sample datas"
1174+
objects := self createTissotIndicatorCircles.
1175+
element addObjects: objects.
1176+
1177+
^ self openViewInWindow: element
1178+
1179+
]
1180+
11521181
{ #category : #'examples - dshapeslayer' }
11531182
GeoViewExamples class >> exampleVisibilityDShapesLayer [
11541183

src/GeoView-Tests/GeoViewAbstractElementTest.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ GeoViewAbstractElementTest >> testInitialize [
175175
self assert: geoView extent equals: 1000 @ 1000.
176176
self
177177
assert: geoView mapProjection class
178-
equals: GeoViewMercatorProjection.
178+
equals: GeoViewWebMercatorProjection.
179179
self
180180
assert: geoView displayToGraphicProjection class
181181
equals: GeoView2DProjection.

0 commit comments

Comments
 (0)