Sie sind auf Seite 1von 3

Spatial Database example SQL/POSTGIS Gianni Gorgoglione

1

Spatial databases

PART 1


1. Abstract data type is an abstract data structure that consists of many behaviors. This data
type is built by operations and constrains that affect this class. The aim of abstract data
type is to classify and describe different programming structures. Basically, ADT is
necessary to create an abstract class for different objects that share same functions or
attributes of one geometrical class.

2. Objects: Lines_ADT, (curves, straight lines, ziz-zag lines)
Operation: geometry (dimension, length, intersection,buffer)
Objects: Polygons_ADT (rectagles, square, etc)
Operation: geometry (union, intersection, overlaps)

3. SELECT student.name, student.familyname ,courses.name, CourseResults.grade
FROM Student, CourseResults, Courses
WHERE course.name= GIS-algorithms
AND grade = 10

PART 2

1. SELECT * FROM cities
SELECT * FROM countries
SELECT * FROM rivers

the_geom


2. SELECT cities.city_name
FROM cities
WHERE cntry_name='Sweden'

Spatial Database example SQL/POSTGIS Gianni Gorgoglione
2

3. Is a method that returns value TRUE if there are not anomalous points as self intersection
or self tangency.
SELECT * from rivers
WHERE NOT issimple(the_geom)
Number of matching posts: 20







The river on the right side has a self -intersection
4. SELECT rivers.name,rivers.the_geom
FROM rivers , countries
WHERE INTERSECTS(rivers.the_geom, countries.the_geom)='TRUE'
AND countries.cntry_name='Switzerland'
GROUP BY rivers.name,rivers.the_geom

5. a. EQUAL functions will return identical geometry for x and y coordinates
b. SELECT DISTINCT rivers.name,length
FROM rivers
c. SELECT DISTINCT rivers.name,length
FROM rivers
WHERE rivers.name='Thames'

Thames 245709.5

SELECT ST_LENGTH(rivers.the_geom),rivers.name
FROM rivers
WHERE rivers.name='Thames'
1- 245709.494366365
Spatial Database example SQL/POSTGIS Gianni Gorgoglione
3


Yes, they look identical


d. SELECT MAX(length)
FROM rivers
Longest river 761227.430000000051223


6. SELECT ST_Distance(cities.the_geom, rivers.the_geom)
FROM cities, rivers
WHERE city_name='London' AND rivers.name='Thames'

The distance between London and Thames river is 3857.38

The command St_Distance calculates the distance between two objects by taking the
minimum distance of the two geometries. The calculation might take only into account a
Cartesian space and not a Sphere projection.

However, it is important to define the points of interest necessary to decide where the
start and end point are located in order to calculate the distance. The main reason of this
importance is represented by the fact that simply Thames river crosses London. Thus, it is
important to understand how London city is represented in Citys geometry as well the
rivers one.
However, in the end, it seems to be wrong all the calculation for the reason explained
above-mentioned.



7.
SELECT c1.cntry_name
FROM countries AS c1, countries AS c2
WHERE ST_Touches(c1.the_geom, c2.the_geom)='1'
AND c2.cntry_name='Sweden'

Das könnte Ihnen auch gefallen