Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions src/GeoView-Examples/GeoViewExamples.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,18 @@ GeoViewExamples class >> exampleGeoSegmentsProjected [
{ #category : #'examples - tiles provider' }
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingGoogleHybrid [
"This example show a map layer (assuming an internet connection to default url of google"

| element layer |
element := GeoViewAeElement new.
element maxScaleInMeters: element maxScaleInMeters * 8.

element maxScaleInMeters: element maxScale * 8.

"add carto layer"
layer := GeoViewMapTilesLayer newWithGoogle name: 'Tiles Layer'.
layer tilesProvider beHybridType.
element addLayer: layer.

^ self openViewInWindow: element

]

{ #category : #'examples - tiles provider' }
Expand Down Expand Up @@ -505,29 +504,37 @@ GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerUsingOSMWithSmallTileS
{ #category : #examples }
GeoViewExamples class >> exampleGeoViewWithCartoTilesLayerWithUpdateCenter [
"This example show a map layer with update of map center every seconds (during 30s)"
| element layer newCenter space circle|

| element layer newCenter space circle |
element := GeoViewUtils createGeoViewForGeoObjects.
element maxScaleInMeters: element maxScaleInMeters * 8.
element scaleInMeters: 150000.

element maxScaleInMeters: element maxScale * 8.
element scale: 150000.

"add carto layer"
element addLayerAtFirst: GeoViewMapTilesLayer new.

circle := GeoCircle new key: 1; radiusInMeters: 2000; fillStyle: (Color red asSmockStrokeStyle); absoluteCoordinates: AbsoluteCoordinates frBrest.

circle := GeoCircle new
key: 1;
radiusInMeters: 2000;
fillStyle: Color red asSmockStrokeStyle;
absoluteCoordinates: AbsoluteCoordinates frBrest.
element addObject: circle.
space := self openViewInWindow: element.

newCenter := AbsoluteCoordinates frBrest copy.
[ (1 to: 30) do:[:i | 1 seconds wait.
newCenter := AbsoluteCoordinates latitudeInDegrees: (newCenter latitudeInDegrees + 0.05) longitudeInDegrees: (newCenter longitudeInDegrees + 0.05).
element geoCenter: newCenter.
circle absoluteCoordinates:newCenter.
element updateObjects: (OrderedCollection with: circle).
]
] forkAt: Processor userBackgroundPriority

[
(1 to: 30) do: [ :i |
1 seconds wait.
newCenter := AbsoluteCoordinates
latitudeInDegrees:
newCenter latitudeInDegrees + 0.05
longitudeInDegrees:
newCenter longitudeInDegrees + 0.05.
element geoCenter: newCenter.
circle absoluteCoordinates: newCenter.
element updateObjects: (OrderedCollection with: circle) ] ]
forkAt: Processor userBackgroundPriority
]

{ #category : #'examples - data' }
Expand Down
36 changes: 34 additions & 2 deletions src/GeoView-Molecule/GeoViewManagerImpl.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ GeoViewManagerImpl >> getGlobalPointFromLocalPoint: aLocalPoint [
^ self getView globalPointFromLocalPoint: aLocalPoint
]

{ #category : #'parameters - interactions' }
GeoViewManagerImpl >> getInteractionsStrategy [

^ self getView interactionsStrategy
]

{ #category : #'services - layer' }
GeoViewManagerImpl >> getLayer: aKey [

Expand Down Expand Up @@ -208,6 +214,12 @@ GeoViewManagerImpl >> getObjectIndexAccessor [
^ self view objectIndexAccessor
]

{ #category : #services }
GeoViewManagerImpl >> getScale [

^ self view scale
]

{ #category : #services }
GeoViewManagerImpl >> getScaleFactor [

Expand All @@ -217,7 +229,11 @@ GeoViewManagerImpl >> getScaleFactor [
{ #category : #services }
GeoViewManagerImpl >> getScaleInMeters [

^ self view scaleInMeters
self
deprecated:'Use generic message'
transformWith: '`@receiver getScaleInMeters' -> '`@receiver getScale'.

^ self getScale
]

{ #category : #'component accessing' }
Expand Down Expand Up @@ -449,6 +465,12 @@ GeoViewManagerImpl >> setGeoCenter: anAbsoluteCoordinates [
self view geoCenter: anAbsoluteCoordinates
]

{ #category : #'parameters - interactions' }
GeoViewManagerImpl >> setInteractionsStrategy: aStrategy [

self getView setInteractionsStrategy: aStrategy
]

{ #category : #'services - map projection' }
GeoViewManagerImpl >> setMapProjection: aMapProjection [

Expand All @@ -461,6 +483,12 @@ GeoViewManagerImpl >> setObjectIndexAccessor: aSymbol [
self getView objectIndexAccessor: aSymbol
]

{ #category : #services }
GeoViewManagerImpl >> setScale: aNumber [

self view scale: aNumber
]

{ #category : #services }
GeoViewManagerImpl >> setScaleFactor: aNumber [

Expand All @@ -470,7 +498,11 @@ GeoViewManagerImpl >> setScaleFactor: aNumber [
{ #category : #services }
GeoViewManagerImpl >> setScaleInMeters: aNumber [

self view scaleInMeters: aNumber
self
deprecated:'Use generic message'
transformWith: '`@receiver setScaleInMeters: `@aNumber' -> '`@receiver setScale: `@aNumber'.

self setScale: aNumber
]

{ #category : #'parameters - selection manager' }
Expand Down
8 changes: 8 additions & 0 deletions src/GeoView-Molecule/GeoViewManagerParameters.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Trait {
GeoViewManagerParameters >> getDisplayToGraphicProjection [
]

{ #category : #'parameters - interactions' }
GeoViewManagerParameters >> getInteractionsStrategy [
]

{ #category : #'parameters - objects' }
GeoViewManagerParameters >> getObjectIndexAccessor [
]
Expand All @@ -24,6 +28,10 @@ GeoViewManagerParameters >> getViewInfos [
GeoViewManagerParameters >> setDisplayToGraphicProjection: aGeoView2DProjection [
]

{ #category : #'parameters - interactions' }
GeoViewManagerParameters >> setInteractionsStrategy: aStrategy [
]

{ #category : #'parameters - objects' }
GeoViewManagerParameters >> setObjectIndexAccessor: aSymbol [
]
Expand Down
8 changes: 4 additions & 4 deletions src/GeoView-Molecule/GeoViewManagerServices.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ GeoViewManagerServices >> getMapProjection [
]

{ #category : #services }
GeoViewManagerServices >> getScaleFactor [
GeoViewManagerServices >> getScale [
]

{ #category : #services }
GeoViewManagerServices >> getScaleInMeters [
GeoViewManagerServices >> getScaleFactor [
]

{ #category : #services }
Expand Down Expand Up @@ -105,9 +105,9 @@ GeoViewManagerServices >> setMapProjection: aMapProjection [
]

{ #category : #services }
GeoViewManagerServices >> setScaleFactor: aNumber [
GeoViewManagerServices >> setScale: aNumber [
]

{ #category : #services }
GeoViewManagerServices >> setScaleInMeters: aNumber [
GeoViewManagerServices >> setScaleFactor: aNumber [
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Class {

{ #category : #running }
AbstractGeoViewGraphicModelLayerTest >> setUp [

super setUp.

layer := AbstractGeoViewGraphicModelLayer new
Expand Down Expand Up @@ -144,6 +145,7 @@ AbstractGeoViewGraphicModelLayerTest >> testNeedToSortDatas [
AbstractGeoViewGraphicModelLayerTest >> testReachMaximumDisplayedObjects [

| objects |
layer graphicProjection: (GeoView2DProjection new resolution: (10 asPoint)).
layer maximumDisplayedObjects: 50.

objects := (1 to: 100) collect:[ :e | SmockDCircle new key: e; radius: 10; coordinates: 0@0; fillColor: Color red ].
Expand Down
56 changes: 42 additions & 14 deletions src/GeoView-Tests/GeoView2DProjectionTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ GeoView2DProjectionTest >> setUp [
projection := GeoView2DProjection new
]

{ #category : #tests }
GeoView2DProjectionTest >> testAltitudeInMeters [

self assert: projection altitudeInMeters equals: (projection defaultAltitudeInMeters).

projection altitudeInMeters: 1.
self assert: projection altitudeInMeters equals: 1.


]

{ #category : #tests }
GeoView2DProjectionTest >> testBoundsInPixels [

Expand All @@ -53,10 +42,10 @@ GeoView2DProjectionTest >> testExtentInPixels [
{ #category : #tests }
GeoView2DProjectionTest >> testMetersByPixel [

self assert: projection metersByPixel equals: 0@0.
self assert: projection metersByPixel equals: 0.

projection metersByPixel: 1 asPoint.
self assert: projection metersByPixel equals: 1 asPoint.
projection resolution: 1 asPoint.
self assert: projection metersByPixel equals: 1.


]
Expand All @@ -71,3 +60,42 @@ GeoView2DProjectionTest >> testOffsetInPixels [


]

{ #category : #tests }
GeoView2DProjectionTest >> testScale [

self assert: projection scale isNil.

projection scale: 1.
self assert: projection scale equals: 1.


]

{ #category : #tests }
GeoView2DProjectionTest >> testUpdateResolution [

"not supported values"
projection updateResolution: nil.
self assert: projection resolution equals: 0 asPoint.

projection updateResolution: 1.
self assert: projection resolution equals: 0 asPoint.

projection updateResolution: 100@100.
self assert: projection resolution equals: 0 asPoint.

"setup a scale to update"
projection scale: 1000000.

"not supported values"
projection updateResolution: nil.
self assert: projection resolution equals: 0 asPoint.

projection updateResolution: 1.
self assert: projection resolution equals: 0 asPoint.

"supported values"
projection updateResolution: 100@100.
self assert: projection resolution equals: (1/20000 asPoint).
]
67 changes: 67 additions & 0 deletions src/GeoView-Tests/GeoViewAbstractElementTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,47 @@ GeoViewAbstractElementTest >> testInteractionsStrategy [
self assert: geoView interactionsStrategy class equals: GeoViewInteractionsStrategy
]

{ #category : #tests }
GeoViewAbstractElementTest >> testMaxScale [

self assert: geoView maxScale equals: 100000000.

geoView maxScale: 10000000.
self assert: geoView maxScale equals: 10000000.
]

{ #category : #tests }
GeoViewAbstractElementTest >> testMinScale [

self assert: geoView minScale equals: 100.

geoView minScale: 500.
self assert: geoView minScale equals: 500.
]

{ #category : #tests }
GeoViewAbstractElementTest >> testNewInteractionsStrategy [

self assert: geoView newInteractionsStrategy class equals: GeoViewInteractionsStrategy.
]

{ #category : #tests }
GeoViewAbstractElementTest >> testNormalizeScale [

"Min"
self assert: (geoView normalizeScale: geoView minScale) equals: (geoView minScale).
self assert: (geoView normalizeScale: 100) equals: 100.
self assert: (geoView normalizeScale: 1) equals: 100.

"Max"
self assert: (geoView normalizeScale: geoView maxScale) equals: (geoView maxScale).
self assert: (geoView normalizeScale: 100000000) equals: 100000000.
self assert: (geoView normalizeScale: 1000000000) equals: 100000000.

"Middle"
self assert: (geoView normalizeScale: 10000) equals: 10000.
]

{ #category : #tests }
GeoViewAbstractElementTest >> testObjectIndexAccessor [

Expand Down Expand Up @@ -316,6 +351,38 @@ GeoViewAbstractElementTest >> testRemoveLayer [
self assert: (geoView getLayer: #test) isNil
]

{ #category : #tests }
GeoViewAbstractElementTest >> testScale [

self assert: geoView scale equals: geoView defaultScale.

geoView scale: 100000.
self assert: geoView scale equals: 100000
]

{ #category : #tests }
GeoViewAbstractElementTest >> testScaleDown [

geoView scaleDown.
self assert: geoView scale equals: (geoView defaultScale * geoView scaleFactor).
]

{ #category : #tests }
GeoViewAbstractElementTest >> testScaleFactor [

self assert: geoView scaleFactor equals: 1.5.

geoView scaleFactor: 2.
self assert: geoView scaleFactor equals: 2
]

{ #category : #tests }
GeoViewAbstractElementTest >> testScaleUp [

geoView scaleUp.
self assert: geoView scale equals: (geoView defaultScale / geoView scaleFactor).
]

{ #category : #tests }
GeoViewAbstractElementTest >> testSetInteractionsStrategy [

Expand Down
Loading
Loading