Support to GeoJson in Ontologies on PostGIS
This functionality is available from version 2.0.0.0
Introduction
In this tutorial, you will see how GeoJson is supported in ontologies on PostGIS in the Platform. To do this, you will first create a georeferenced virtual ontology on PostGIS and then you will create a GIS viewer on platform using that ontology.
Creating a virtual ontology
JDBC Connection
The first step to create a virtual ontology is to create a JDBC connection to the relational database, which in this case will be PostGIS.
For more information on how to create a JDBC connection, see this other tutorial: How to create a JDBC connection to a relational database.
Virtual Ontology
Once the JDBC connection is created, you can proceed to create the virtual ontology. To do so, access to the menu option DEVELOPMENT > My Ontologies and the list of ontologies of your user will appear.
Select the CREATE button and select the option:
For this example, you are going to create an ontology of an existing table in our PostGIS. Thus, in the form that will appear, you will have to select on one side the JDBC connection that you have created in the previous step and, on the other side, the table.
For more information on how to create an ontology on a relational database, see the tutorial: Creation from a relational database
For this example, you will select the POINT table from the JDBC POSTGIS connection and the ontology will be called buildings.
The next step is to assign the 'id' and 'geometry' fields:
In this case, associate the ID field of the table with the unique identifier, and the GEOMETRY field of the table with the georeferenced field of the ontology.
Once the ontology schema has been generated, click on the NEW button to create it.
Once the ontology is created, you can go to the QueryTool and launch a query on this ontology, to check that you are accessing correctly to the PostGIS’s 'point' table .
[
{
"geometry": "{\"type\":\"Point\",\"coordinates\":[-3.6981,40.4204]}",
"id": "1",
"status": false
},
{
"geometry": "{\"type\":\"Point\",\"coordinates\":[-3.6998,40.422]}",
"id": "2",
"status": false
},
{
"geometry": "{\"type\":\"Point\",\"coordinates\":[-3.6975,40.4221]}",
"id": "3",
"status": true
},
{
"geometry": "{\"type\":\"Point\",\"coordinates\":[-3.7033,40.4229]}",
"id": "4",
"status": true
},
{
"geometry": "{\"type\":\"Point\",\"coordinates\":[-3.6955,40.4232]}",
"id": "5",
"status": true
}
]
Creating the GIS viewer
Next, you are going to create a simple GIS viewer using the ontology you have just created. To do this, you will need to create a layer associated to that ontology.
Creating a layer
Go to the menu option VISUALIZATIONS & GIS > My GIS Layers, select the CREATE button and select the option:
Then, fill in the form. When selecting a virtual ontology, you will be asked to select the type of geometry that stores that ontology (in this case, POINT). This is because in PostGis, you can store both points and lines and polygons in the same table .
For this example, you will use the symbology filters, so you have to select different colors for the points depending on the ontology status field:
You are also going to select the 'id' and 'status' fields to appear in the 'infobox'.
Once your layer is configured, select the NEW button to create it.
Create viewer
The next step is to create the GIS viewer and add the layer you have just created. To do this, go to the menu option VISUALIZATIONS & GIS > My GIS Viewers, click on the CREATE button and fill out the form:
In this case, you will be are painting points over Madrid, so you must select the starting coordinates in that area.
In the preview of the viewer, you can see your points drawn on the map, and, as expected, 3 of them appear in green and 2 of them in red. This is due to the filters of the symbology that you have configured at the time of creating your layer.
Besides, if you click on one of the points, you will see that the information box will appear with the data that you have configured in the layer:
Â