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;








2















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.










share|improve this question




























    2















    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.










    share|improve this question
























      2












      2








      2








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 14:08









      IñigoIñigo

      295 bronze badges




      295 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          1














          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))





          share|improve this answer























          • You were right, thanks!

            – Iñigo
            Mar 26 at 7:52


















          3














          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
          );





          share|improve this answer























          • You were right! But I finally transformed the coordinate on the server side, thanks.

            – Iñigo
            Mar 26 at 7:53













          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
          );



          );













          draft saved

          draft discarded


















          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









          1














          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))





          share|improve this answer























          • You were right, thanks!

            – Iñigo
            Mar 26 at 7:52















          1














          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))





          share|improve this answer























          • You were right, thanks!

            – Iñigo
            Mar 26 at 7:52













          1












          1








          1







          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))





          share|improve this answer













          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))






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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













          3














          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
          );





          share|improve this answer























          • You were right! But I finally transformed the coordinate on the server side, thanks.

            – Iñigo
            Mar 26 at 7:53















          3














          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
          );





          share|improve this answer























          • You were right! But I finally transformed the coordinate on the server side, thanks.

            – Iñigo
            Mar 26 at 7:53













          3












          3








          3







          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
          );





          share|improve this answer













          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
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현