Book Image

Mastering PostGIS

By : Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz
Book Image

Mastering PostGIS

By: Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz

Overview of this book

PostGIS is open source extension onf PostgreSQL object-relational database system that allows GIS objects to be stored and allows querying for information and location services. The aim of this book is to help you master the functionalities offered by PostGIS- from data creation, analysis and output, to ETL and live edits. The book begins with an overview of the key concepts related to spatial database systems and how it applies to Spatial RMDS. You will learn to load different formats into your Postgres instance, investigate the spatial nature of your raster data, and finally export it using built-in functionalities or 3th party tools for backup or representational purposes. Through the course of this book, you will be presented with many examples on how to interact with the database using JavaScript and Node.js. Sample web-based applications interacting with backend PostGIS will also be presented throughout the book, so you can get comfortable with the modern ways of consuming and modifying your spatial data.
Table of Contents (9 chapters)

Enabling CORS in Jetty


Because our GeoServer is hosted at a different origin than our web application (a different port is enough to make a domain be considered by a browser to be a different origin; an origin is a combination of protocol, host, and port), we will not be able to perform AJAX requests straight away as the browser will refuse to retrieve the data from such a location. This is due to the same-origin policy that is meant to prevent scripts from untrusted sources gaining access to the DOM of a page.

CORS (Cross Origin Resource Sharing) is a standard mechanism for cross origin communication between browsers and servers. The CORS specification defines a set of headers that are used to communicate which operations are allowed. Thanks to that, it is possible to expose APIs that can be consumed by web clients located in different domains than the API itself.

In order to enable our web apps to send AJAX requests to our remote GeoServer, we need to enable CORS in our Jetty server. In...