How to center openlayers map from PostGIS coordinates?How to exit from PostgreSQL command line utility: psqlOpenLayers: transform GPS coordinates to EPSG:25832OpenLayers: convert EPSG:3006 to EPSG:4326How to convert “normal” coordinates to OSM coordinates in OpenLayersOpenLayers Map Projections with Proj4JSWFS-T add point to postGIS table via Openlayers 3 / geoserverReproject EPSG:28992 to EPSG:3857 (defaults to EPSG:4326)PostgreSQL raw SQL insert (Laravel 5.5)EPSG:3395 Projection not providing map wrappingThe data entered to the postgres db is altered somehow?
Reusable spacecraft: why still have fairings detach, instead of open/close?
Can one use the present progressive or gerund like an adjective?
How to describe POV characters?
Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?
How to properly say asset/assets in German
What verb for taking advantage fits in "I don't want to ________ on the friendship"?
Can SOCPs approximate better than LPs?
Different budgets within roommate group
What is "oversubscription" in Networking?
13th chords on guitar
What do you call a notepad used to keep a record?
Losing queen and then winning the game
I need help with pasta
Using the ArcGIS 'select by location' tool in ModelBuilder?
Was it really unprofessional of me to leave without asking for a raise first?
Why do I need two parameters in an HTTP parameter pollution attack?
Will writing actual numbers instead of writing them with letters affect readership?
Is Cyclic Ether oxidised by periodic acid
What exactly did Ant-Man see that made him say that their plan worked?
Just graduated with a master’s degree, but I internalised nothing
How do I tell the reader that my character is autistic in Fantasy?
What are good ways to spray paint a QR code on a footpath?
If two black hole event horizons overlap (touch) can they ever separate again?
How do I organize members in a struct to waste the least space on alignment?
How to center openlayers map from PostGIS coordinates?
How to exit from PostgreSQL command line utility: psqlOpenLayers: transform GPS coordinates to EPSG:25832OpenLayers: convert EPSG:3006 to EPSG:4326How to convert “normal” coordinates to OSM coordinates in OpenLayersOpenLayers Map Projections with Proj4JSWFS-T add point to postGIS table via Openlayers 3 / geoserverReproject EPSG:28992 to EPSG:3857 (defaults to EPSG:4326)PostgreSQL raw SQL insert (Laravel 5.5)EPSG:3395 Projection not providing map wrappingThe data entered to the postgres db is altered somehow?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to center my openlayers map with a coordinate obtained from my database with the PostGIS functions: ST_AsGeoJSON(ST_SetSRID(ST_Centroid(geom),3857))
. The geometry in my database is projected in EPSG:25830 and my openlayers map is projected in EPSG:3857.
The coordinate I get on the client side once I call the server is like this:
613056.633587271 4738175.03852526
Then I do the following with the openlayers map's view and the coordinate received:
view.animate(
center: coordinatefromserver,
duration: 500
);
And my map moves to a totally different position.
The kind of coordinate that I know that works fine is this one:
-180099.9705826787,5279777.85057039
What am I missing? PostGIS functions? Any type conversion? Projections? Sorry, but I'm pretty noobie in this!
Thanks.
postgresql gis openlayers postgis
add a comment |
I'm trying to center my openlayers map with a coordinate obtained from my database with the PostGIS functions: ST_AsGeoJSON(ST_SetSRID(ST_Centroid(geom),3857))
. The geometry in my database is projected in EPSG:25830 and my openlayers map is projected in EPSG:3857.
The coordinate I get on the client side once I call the server is like this:
613056.633587271 4738175.03852526
Then I do the following with the openlayers map's view and the coordinate received:
view.animate(
center: coordinatefromserver,
duration: 500
);
And my map moves to a totally different position.
The kind of coordinate that I know that works fine is this one:
-180099.9705826787,5279777.85057039
What am I missing? PostGIS functions? Any type conversion? Projections? Sorry, but I'm pretty noobie in this!
Thanks.
postgresql gis openlayers postgis
add a comment |
I'm trying to center my openlayers map with a coordinate obtained from my database with the PostGIS functions: ST_AsGeoJSON(ST_SetSRID(ST_Centroid(geom),3857))
. The geometry in my database is projected in EPSG:25830 and my openlayers map is projected in EPSG:3857.
The coordinate I get on the client side once I call the server is like this:
613056.633587271 4738175.03852526
Then I do the following with the openlayers map's view and the coordinate received:
view.animate(
center: coordinatefromserver,
duration: 500
);
And my map moves to a totally different position.
The kind of coordinate that I know that works fine is this one:
-180099.9705826787,5279777.85057039
What am I missing? PostGIS functions? Any type conversion? Projections? Sorry, but I'm pretty noobie in this!
Thanks.
postgresql gis openlayers postgis
I'm trying to center my openlayers map with a coordinate obtained from my database with the PostGIS functions: ST_AsGeoJSON(ST_SetSRID(ST_Centroid(geom),3857))
. The geometry in my database is projected in EPSG:25830 and my openlayers map is projected in EPSG:3857.
The coordinate I get on the client side once I call the server is like this:
613056.633587271 4738175.03852526
Then I do the following with the openlayers map's view and the coordinate received:
view.animate(
center: coordinatefromserver,
duration: 500
);
And my map moves to a totally different position.
The kind of coordinate that I know that works fine is this one:
-180099.9705826787,5279777.85057039
What am I missing? PostGIS functions? Any type conversion? Projections? Sorry, but I'm pretty noobie in this!
Thanks.
postgresql gis openlayers postgis
postgresql gis openlayers postgis
asked Mar 25 at 14:08
IñigoIñigo
295 bronze badges
295 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Pretty sure the problem is that your query is not doing what you want. If you want to transform from one srid to another you need to use st_transform and not st_setsrid.
I.e. your query should be:
ST_AsGeoJSON(ST_transform(ST_Centroid(geom),3857))
You were right, thanks!
– Iñigo
Mar 26 at 7:52
add a comment |
When transformed from EPSG:25830 to EPSG:3857 those coordinates produce [-180081.82283603796, 5279725.360517778] so the server is returning EPSG:25830 despite the SetSRID 3857.
You can do the transform in OpenLayers:
proj4.defs('EPSG:25830', '+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ');
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4); // only needed for OL5
view.animate(
center: ol.proj.transform(coordinatefromserver, 'EPSG:25830', view.getProjection())
duration: 500
);
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339717%2fhow-to-center-openlayers-map-from-postgis-coordinates%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Pretty sure the problem is that your query is not doing what you want. If you want to transform from one srid to another you need to use st_transform and not st_setsrid.
I.e. your query should be:
ST_AsGeoJSON(ST_transform(ST_Centroid(geom),3857))
You were right, thanks!
– Iñigo
Mar 26 at 7:52
add a comment |
Pretty sure the problem is that your query is not doing what you want. If you want to transform from one srid to another you need to use st_transform and not st_setsrid.
I.e. your query should be:
ST_AsGeoJSON(ST_transform(ST_Centroid(geom),3857))
You were right, thanks!
– Iñigo
Mar 26 at 7:52
add a comment |
Pretty sure the problem is that your query is not doing what you want. If you want to transform from one srid to another you need to use st_transform and not st_setsrid.
I.e. your query should be:
ST_AsGeoJSON(ST_transform(ST_Centroid(geom),3857))
Pretty sure the problem is that your query is not doing what you want. If you want to transform from one srid to another you need to use st_transform and not st_setsrid.
I.e. your query should be:
ST_AsGeoJSON(ST_transform(ST_Centroid(geom),3857))
answered Mar 25 at 15:27
mlinthmlinth
2,2856 gold badges20 silver badges25 bronze badges
2,2856 gold badges20 silver badges25 bronze badges
You were right, thanks!
– Iñigo
Mar 26 at 7:52
add a comment |
You were right, thanks!
– Iñigo
Mar 26 at 7:52
You were right, thanks!
– Iñigo
Mar 26 at 7:52
You were right, thanks!
– Iñigo
Mar 26 at 7:52
add a comment |
When transformed from EPSG:25830 to EPSG:3857 those coordinates produce [-180081.82283603796, 5279725.360517778] so the server is returning EPSG:25830 despite the SetSRID 3857.
You can do the transform in OpenLayers:
proj4.defs('EPSG:25830', '+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ');
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4); // only needed for OL5
view.animate(
center: ol.proj.transform(coordinatefromserver, 'EPSG:25830', view.getProjection())
duration: 500
);
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
add a comment |
When transformed from EPSG:25830 to EPSG:3857 those coordinates produce [-180081.82283603796, 5279725.360517778] so the server is returning EPSG:25830 despite the SetSRID 3857.
You can do the transform in OpenLayers:
proj4.defs('EPSG:25830', '+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ');
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4); // only needed for OL5
view.animate(
center: ol.proj.transform(coordinatefromserver, 'EPSG:25830', view.getProjection())
duration: 500
);
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
add a comment |
When transformed from EPSG:25830 to EPSG:3857 those coordinates produce [-180081.82283603796, 5279725.360517778] so the server is returning EPSG:25830 despite the SetSRID 3857.
You can do the transform in OpenLayers:
proj4.defs('EPSG:25830', '+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ');
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4); // only needed for OL5
view.animate(
center: ol.proj.transform(coordinatefromserver, 'EPSG:25830', view.getProjection())
duration: 500
);
When transformed from EPSG:25830 to EPSG:3857 those coordinates produce [-180081.82283603796, 5279725.360517778] so the server is returning EPSG:25830 despite the SetSRID 3857.
You can do the transform in OpenLayers:
proj4.defs('EPSG:25830', '+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ');
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4); // only needed for OL5
view.animate(
center: ol.proj.transform(coordinatefromserver, 'EPSG:25830', view.getProjection())
duration: 500
);
answered Mar 25 at 14:39
MikeMike
3,9902 gold badges2 silver badges13 bronze badges
3,9902 gold badges2 silver badges13 bronze badges
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
add a comment |
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
You were right! But I finally transformed the coordinate on the server side, thanks.
– Iñigo
Mar 26 at 7:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339717%2fhow-to-center-openlayers-map-from-postgis-coordinates%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown