1

I am attempting to create a web map in OpenLayers by pulling in layers from GeoServer which is running on an Amazon EC2 instance. The prepackaged layers from GeoServer seem to show up fine when I substitute their URL in the map code. However I have a PostGIS layer that I am wanting to use as the basis for the map which is not showing up no matter what I try.

I have read several threads that seem to indicate it's a problem with mismatched projections. But I'm not sure where or how to "reproject" the layer or if that is my problem. It does shows up in the GeoServer OpenLayers preview (as a single tile, but not "tiled" for some reason). The declared SRS when I originally published the layer in GeoServer is EPSG:404000. I'm not sure why it is that. Changing it doesn't seem to help.

<!DOCTYPE html>
<html>
  <head>
    <title>Tiled WMS</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var layers = [
        new ol.layer.Tile({
          extent: [-13884991, 2870341, -7455066, 6338219],
          source: new ol.source.TileWMS({
            url: 'http://ec2-18-221-107-236.us-east-2.compute.amazonaws.com:8080/geoserver/Prospect1/wms',
            params: {'LAYERS': 'prospect_leases', 'TILED': true},
            serverType: 'geoserver',
            isBaseLayer: false,
            projection: 'EPSG:404000'
          })
        })
      ];
      var map = new ol.Map({
        layers: layers,
        target: 'map',
        view: new ol.View({
          center: ol.proj.transform([-97.3311, 33.0649], 'EPSG:4326', 'EPSG:3857'),
          zoom: 16
        })
      });
    </script>
  </body>
</html>
5
  • How is the data being served by GeoServer, is it WMS, WCS, WFS, or something else? What is your PostGIS data?
    – nmtoken
    Dec 19, 2017 at 18:01
  • The postgis layer is a shapefile. It is being served up as a WMS
    – Jordan R.
    Dec 19, 2017 at 18:08
  • I should have said can you edit the question to add those details (still applies :) I don't think you can hold a shapefile in PostGIS just import one. So what command did you use to load the data, does it honour the projection of the shapefile
    – nmtoken
    Dec 19, 2017 at 18:27
  • Sorry I should have added that. I uploaded the shapefile to postgres, also on an Amazon instance (RDS).
    – Jordan R.
    Dec 19, 2017 at 18:33
  • How did you add the shapefile to postgis?
    – Ian Turton
    Dec 19, 2017 at 19:23

2 Answers 2

2

I finally did figure this out. I had not actually declared a coordinate system in the SRIS field of the PostGIS shapefile importer/loader.

1

The declared SRS when I originally published the layer in GeoServer is EPSG:404000.

I suspect it's still an SRS issue, according to http://spatialreference.org/ref/sr-org/7589/, it's a 2D wildcard coordinate reference system in meters. The WKT for the SRS does not show much useful information (e.g. datum is unknown...):

LOCAL_CS["Wildcard 2D cartesian plane in metric unit",LOCAL_DATUM["Unknown",0],UNIT["m",1.0],AXIS["x",EAST],AXIS["y",NORTH],AUTHORITY["EPSG","404000"]]

Maybe you can load the PostGIS layer in QGIS first and see if it aligns well with any other layer with well-defined SRS (e.g. WGS84).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.