-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use projection definition provide by server (including projection extent) #280
Merged
Merged
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
306a312
Use crs object provide by server. In case of AddLayer register new Pr…
volterra79 60bf709
Merge branch 'dev' into extent_crs
volterra79 03d5e4f
Create a API_BASE_URLS constant to constant.js and add CRS url
volterra79 2156b58
Add case of server error request not register crs
volterra79 1919017
Merge branch 'dev' into extent_crs
volterra79 e162333
add since tags
Raruto 688ee5b
remove wrong version
Raruto 51b6190
add since version
Raruto 5c94818
Merge branch 'dev' into extent_crs
volterra79 5d95f3e
Merge remote-tracking branch 'origin/extent_crs' into extent_crs
volterra79 2ecfd76
Merge branch 'dev' into extent_crs
volterra79 da1c867
Merge branch 'dev' into extent_crs
volterra79 e9607e1
Changes not related to the pull request. Refactoring it other pull re…
volterra79 c66bdc4
Add missing import module Projections
volterra79 117ce3b
Export API_BASE_URLS
volterra79 2affa04
Changes not related to the pull request. Refactoring it other pull re…
volterra79 53d9f41
Merge branch 'dev' into extent_crs
volterra79 dbac6b5
Change as suggest https://github.com/g3w-suite/g3w-client/pull/280#di…
volterra79 da4f803
Change as suggest https://github.com/g3w-suite/g3w-client/pull/280#di…
volterra79 d1f3848
Change as https://github.com/g3w-suite/g3w-client/pull/280#discussion…
volterra79 8220e9a
Add comments as suggest https://github.com/g3w-suite/g3w-client/pull/…
volterra79 547c58d
Merge branch 'dev' into extent_crs
volterra79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
const utils = require('core/utils/ol'); | ||
const maphelpers = require('./map/maphelpers'); | ||
|
||
const helpers = utils.merge({}, maphelpers); | ||
|
||
module.exports = { | ||
helpers: helpers | ||
helpers | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,52 @@ | ||
import {API_BASE_URLS} from 'constant'; | ||
const Projection = require('./projection'); | ||
const ADDEDPROJECTIONS = ['EPSG:4326', 'EPSG:3857']; | ||
const {XHR} = require('core/utils/utils'); | ||
const {normalizeEpsg} = require('core/utils/geo'); | ||
|
||
const Projections = { | ||
|
||
isRegistered(epsg) { | ||
return ol.proj.get(epsg); | ||
}, | ||
|
||
get(crs={}) { | ||
const cachedProjection = ADDEDPROJECTIONS.indexOf(crs.epsg) !== -1 ? ol.proj.get(crs.epsg) : null; | ||
const cachedProjection = this.isRegistered(crs.epsg); | ||
if (cachedProjection) return cachedProjection; | ||
const projection = new Projection({ | ||
crs | ||
}); | ||
ol.proj.addProjection(projection); | ||
ADDEDPROJECTIONS.push(crs.epsg); | ||
ol.proj.proj4.register(proj4); | ||
return projection; | ||
}, | ||
|
||
/** | ||
* extent get from https://epsg.io/ | ||
* Check and register epsg | ||
* | ||
* @param epsg : "EPSG:<CODE>" Ex. "EPSG:4326" | ||
* @returns {Promise<unknown>} | ||
Raruto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @since v3.8 | ||
*/ | ||
setApplicationProjections() { | ||
this.get({ | ||
epsg: "EPSG:3003", | ||
proj4: "+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [1290650.93, 4190305.78, 2343702.24, 5261004.57] | ||
}); | ||
|
||
this.get({ | ||
epsg: "EPSG:3004", | ||
proj4: "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [1782205.39, 4190307.02, 2834974.5, 5250474.42] | ||
}); | ||
|
||
this.get({ | ||
epsg: "EPSG:3045", | ||
proj4:"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", | ||
axisinverted: true, | ||
geographic: false, | ||
extent: [-2465144.8, 3638055.41, 2885759.28, 9493779.8] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:6708", | ||
proj4:"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", | ||
axisinverted: true, | ||
geographic: false, | ||
extent: [-331278.39, 3846440.97, 865258.04, 5256332.65] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:32632", | ||
proj4:"+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [166021.44, 0.0, 833978.56, 9329005.18] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:32633", | ||
proj4:"+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [166021.44, 0.0, 833978.56, 9329005.18] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:32634", | ||
proj4:"+proj=utm +zone=34 +datum=WGS84 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [166021.44, 0.0, 833978.56, 9329005.18] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:25833", | ||
proj4:"+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [-2465144.8,3638055.41,2885759.28, 9493779.8] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:23032", | ||
proj4:"+proj=utm +zone=32 +ellps=intl +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [-1206117.77, 3859932.9, 2582411.08, 8051813.3] | ||
}); | ||
|
||
this.get({ | ||
epsg:"EPSG:23033", | ||
proj4:"+proj=utm +zone=33 +ellps=intl +units=m +no_defs", | ||
axisinverted: false, | ||
geographic: false, | ||
extent: [-1767202.11, 3859945.89, 2023400.16, 8079073.01] | ||
}); | ||
//REGISTER AT THE END THE CUSTOM PROJECTIONS | ||
ol.proj.proj4.register(proj4) | ||
registerProjection(epsg) { | ||
return new Promise((resolve, reject) => { | ||
let projection = this.isRegistered(epsg); | ||
// check if already register | ||
if (projection) resolve(projection); | ||
else { | ||
XHR.get({url: `${API_BASE_URLS.CRS}${epsg.split(':')[1]}`}) | ||
.then(({result, data}) => { | ||
if (result) { | ||
data.epsg = normalizeEpsg(data.epsg); | ||
projection = this.get(data); | ||
ol.proj.proj4.register(proj4); | ||
resolve(projection); | ||
} | ||
}) | ||
.catch(err => reject(err)) | ||
} | ||
}) | ||
} | ||
}; | ||
|
||
}; | ||
|
||
module.exports = Projections; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,19 +15,11 @@ const ApplicationService = require('core/applicationservice'); | |
const ProjectsRegistry = require('core/project/projectsregistry'); | ||
const MapLayersStoreRegistry = require('core/map/maplayersstoresregistry'); | ||
const WFSProvider = require('core/layers/providers/wfsprovider'); | ||
const olhelpers = require('g3w-ol/g3w.ol').helpers; | ||
const {helpers:olhelpers} = require('g3w-ol/g3w.ol'); | ||
const {getScaleFromResolution, getResolutionFromScale} = require('core/utils/ol'); | ||
const ControlsFactory = require('gui/map/control/factory'); | ||
const ControlsRegistry = require('gui/map/control/registry'); | ||
const VectorLayer = require('core/layers/vectorlayer'); | ||
const SETTINGS = { | ||
zoom : { | ||
maxScale: 1000, | ||
}, | ||
animation: { | ||
duration: 2000 | ||
} | ||
}; | ||
|
||
function MapService(options={}) { | ||
this.state = { | ||
|
@@ -229,11 +221,14 @@ function MapService(options={}) { | |
this.viewer = null; | ||
} | ||
this._setupViewer(width, height); | ||
|
||
this.state.bbox = this.viewer.getBBOX(); | ||
this.state.resolution = this.viewer.getResolution(); | ||
this.state.center = this.viewer.getCenter(); | ||
|
||
this._setupAllLayers(); | ||
this.setUpMapOlEvents(); | ||
|
||
this.emit('viewerset'); | ||
}, | ||
controlClick(mapcontrol, info={}) {}, | ||
|
@@ -1672,6 +1667,11 @@ proto._setupViewer = function(width, height) { | |
this.moveDefaultLayersOnTop(zindex); | ||
}); | ||
|
||
/** | ||
* | ||
* Register remove addLayer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. improve documentation about it (it's quite ambiguous) |
||
* | ||
*/ | ||
this.viewer.map.getLayers().on('remove', evt => { | ||
const {element:layer}= evt; | ||
const layerZIndex = layer.getZIndex(); | ||
|
@@ -1734,6 +1734,7 @@ proto._setupListeners = function() { | |
|
||
// SETUP ALL LAYERS | ||
proto._setupAllLayers = function() { | ||
|
||
this._setupBaseLayers(); | ||
this._setupMapLayers(); | ||
this._setupVectorLayers(); | ||
|
@@ -1752,6 +1753,7 @@ proto._setupBaseLayers = function(){ | |
this.mapBaseLayers[layer.getId()] = baseMapLayer; | ||
}); | ||
const reverseBaseLayers = Object.values(this.mapBaseLayers).reverse(); | ||
|
||
reverseBaseLayers.forEach(baseMapLayer => { | ||
baseMapLayer.update(this.state, this.layersExtraParams); | ||
this.addLayerToMap(baseMapLayer) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type of comments (eg. without "external" references) are not very useful, if you really want to communicate something try to be more specific, otherwise it is just additional noise for the reader..