--- a/about.php +++ b/about.php @@ -12,7 +12,7 @@ href="https://github.com/maxious/ACTBus-data">transit feed</a> and <a href="https://github.com/maxious/ACTBus-ui">this site</a> available from github.<br /> -Uses jQuery Mobile, PHP, Ruby, Python, Google Transit Feed Specification tools, OpenTripPlanner, OpenLayers, OpenStreetMap, Cloudmade Geocoder and Tile Service<br /> +Uses jQuery Mobile, PHP, PostgreSQL, OpenTripPlanner, OpenLayers, OpenStreetMap, Cloudmade Geocoder and Tile Service<br /> <br /> Feedback encouraged; contact maxious@lambdacomplex.org<br /> <br />
--- a/aws/awsStartup.sh +++ /dev/null @@ -1,29 +1,1 @@ -#!/bin/bash -#this script should be run from a fresh git checkout from http://maxious.lambdacomplex.org -#ami base must have yum install lighttpd-fastcgi, git, tomcat6 -#screen php-cli php-gd tomcat6-webapps tomcat6-admin-webapps svn maven2 -#http://www.how2forge.org/installing-lighttpd-with-php5-and-mysql-support-on-fedora-12 -cp /root/aws.php /tmp/ -mkdir /var/www/lib/staticmaplite/cache -chcon -h system_u:object_r:httpd_sys_content_t /var/www -chcon -R -h root:object_r:httpd_sys_content_t /var/www/* -chcon -R -t httpd_sys_content_rw_t /var/www/lib/staticmaplite/cache -chmod -R 777 /var/www/lib/staticmaplite/cache -wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ --O /var/www/cbrfeed.zip -easy_install transitfeed -easy_install simplejson -screen -S viewsh -X quit -screen -S viewsh -d -m /var/www/view.sh - -wget http://s3-ap-southeast-1.amazonaws.com/busresources/Graph.obj \ --O /tmp/Graph.obj -rm -rfv /usr/share/tomcat6/webapps/opentripplanner* -wget http://s3-ap-southeast-1.amazonaws.com/busresources/opentripplanner-webapp.war \ --O /usr/share/tomcat6/webapps/opentripplanner-webapp.war -wget http://s3-ap-southeast-1.amazonaws.com/busresources/opentripplanner-api-webapp.war \ --O /usr/share/tomcat6/webapps/opentripplanner-api-webapp.war -/etc/init.d/tomcat6 restart - -
--- /dev/null +++ b/include/common-db.php
--- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -35,39 +35,5 @@ return ""; } } -function viaPoints($tripid, $stopid, $timingPointsOnly = false) -{ - global $APIurl; - $url = $APIurl . "/json/tripstoptimes?trip=" . $tripid; - $json = json_decode(getPage($url)); - debug(print_r($json, true)); - $stops = $json[0]; - $times = $json[1]; - $foundStop = false; - $viaPoints = Array(); - foreach ($stops as $key => $row) { - if ($foundStop) { - if (!$timingPointsOnly || !startsWith($row[5], "Wj")) { - $viaPoints[] = Array( - "id" => $row[0], - "name" => $row[1], - "time" => $times[$key] - ); - } - } - else { - if ($row[0] == $stopid) $foundStop = true; - } - } - return $viaPoints; -} -function viaPointNames($tripid, $stopid) -{ - $points = viaPoints($tripid, $stopid, true); - $pointNames = Array(); - foreach ($points as $point) { - $pointNames[] = $point['name']; - } - return implode(", ", $pointNames); -} + ?>
--- /dev/null +++ b/include/db/route-dao.inc.php @@ -1,1 +1,78 @@ +<?php +function getRoute($routeID) { +/* + def handle_json_GET_routerow(self, params): + schedule = self.server.schedule + route = schedule.GetRoute(params.get('route', None)) + return [transitfeed.Route._FIELD_NAMES, route.GetFieldValuesTuple()] +*/ +} +function getRoutes() { +/* def handle_json_GET_routes(self, params): + """Return a list of all routes.""" + schedule = self.server.schedule + result = [] + for r in schedule.GetRouteList(): + servicep = None + for t in schedule.GetTripList(): + if t.route_id == r.route_id: + servicep = t.service_period + break + result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) + result.sort(key = lambda x: x[1:3]) + return result +*/ +} + +function findRouteByNumber($routeNumber) { + /* + def handle_json_GET_routesearch(self, params): + """Return a list of routes with matching short name.""" + schedule = self.server.schedule + routeshortname = params.get('routeshortname', None) + result = [] + for r in schedule.GetRouteList(): + if r.route_short_name == routeshortname: + servicep = None + for t in schedule.GetTripList(): + if t.route_id == r.route_id: + servicep = t.service_period + break + result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) + result.sort(key = lambda x: x[1:3]) + return result + */ +} + +function getRouteNextTrip($routeID) { + /* + def handle_json_GET_routetrips(self, params): + """ Get a trip for a route_id (preferablly the next one) """ + schedule = self.server.schedule + query = params.get('route_id', None).lower() + result = [] + for t in schedule.GetTripList(): + if t.route_id == query: + try: + starttime = t.GetStartTime() + except: + print "Error for GetStartTime of trip #" + t.trip_id + sys.exc_info()[0] + else: + cursor = t._schedule._connection.cursor() + cursor.execute( + 'SELECT arrival_secs,departure_secs FROM stop_times WHERE ' + 'trip_id=? ORDER BY stop_sequence DESC LIMIT 1', (t.trip_id,)) + (arrival_secs, departure_secs) = cursor.fetchone() + if arrival_secs != None: + endtime = arrival_secs + elif departure_secs != None: + endtime = departure_secs + else: + endtime =0 + result.append ( (starttime, t.trip_id, endtime) ) + return sorted(result, key=lambda trip: trip[2]) + */ +} + +?>
--- /dev/null +++ b/include/db/stop-dao.inc.php @@ -1,1 +1,97 @@ +<?php +/* def StopZoneToTuple(stop): + """Return tuple as expected by javascript function addStopMarkerFromList""" + return (stop.stop_id, stop.stop_name, float(stop.stop_lat), + float(stop.stop_lon), stop.location_type, stop.stop_code, stop.zone_id) +*/ +function getStop($stopID) { + +} + +function getStops($timingPointsOnly = false) { + +} + +function stopsNear($lat,$lng,$limit) { + + /* + -- Show a distance query and note, London is outside the 1000km tolerance + SELECT name FROM global_points WHERE ST_DWithin(location, ST_GeographyFromText('SRID=4326;POINT(-110 29)'), 1000000, FALSE); + // All the geography functions have the option of using a sphere calculation, by setting a final boolean parameter to 'FALSE'. This will somewhat speed up calculations, particularly for cases where the geometries are very simple. + */ +} + +function stopsBySuburb($suburb) { + +} + +function stopRoutes($stopID,$service_period) +/* + def handle_json_GET_stoproutes(self, params): + """Given a stop_id return all routes to visit the stop.""" + schedule = self.server.schedule + stop = schedule.GetStop(params.get('stop', None)) + service_period = params.get('service_period', None) + trips = stop.GetTrips(schedule) + result = {} + for trip in trips: + route = schedule.GetRoute(trip.route_id) + if service_period == None or trip.service_id == service_period: + if not route.route_short_name+route.route_long_name+trip.service_id in result: + result[route.route_short_name+route.route_long_name+trip.service_id] = (route.route_id, route.route_short_name, route.route_long_name, trip.trip_id, trip.service_id) + return result +*/ + +function stopTrips($stopID) { + /* + def handle_json_GET_stopalltrips(self, params): + """Given a stop_id return all trips to visit the stop (without times).""" + schedule = self.server.schedule + stop = schedule.GetStop(params.get('stop', None)) + service_period = params.get('service_period', None) + trips = stop.GetTrips(schedule) + result = [] + for trip in trips: + if service_period == None or trip.service_id == service_period: + result.append((trip.trip_id, trip.service_id)) + return result + */ +} +function stopTripsWithTimes($stopID, $time, $service_period) { + /* + def handle_json_GET_stoptrips(self, params): + """Given a stop_id and time in seconds since midnight return the next + trips to visit the stop.""" + schedule = self.server.schedule + stop = schedule.GetStop(params.get('stop', None)) + requested_time = int(params.get('time', 0)) + limit = int(params.get('limit', 15)) + service_period = params.get('service_period', None) + time_range = int(params.get('time_range', 24*60*60)) + + filtered_time_trips = [] + for trip, index in stop._GetTripIndex(schedule): + tripstarttime = trip.GetStartTime() + if tripstarttime > requested_time and tripstarttime < (requested_time + time_range): + time, stoptime, tp = trip.GetTimeInterpolatedStops()[index] + if time > requested_time and time < (requested_time + time_range): + bisect.insort(filtered_time_trips, (time, (trip, index), tp)) + result = [] + for time, (trip, index), tp in filtered_time_trips: + if len(result) > limit: + break + route = schedule.GetRoute(trip.route_id) + trip_name = '' + if route.route_short_name: + trip_name += route.route_short_name + if route.route_long_name: + if len(trip_name): + trip_name += " - " + trip_name += route.route_long_name + if service_period == None or trip.service_id == service_period: + result.append((time, (trip.trip_id, trip_name, trip.service_id), tp)) + return result + */ +} +?>
--- /dev/null +++ b/include/db/trip-dao.inc.php @@ -1,1 +1,132 @@ +<?php +function getTrip($tripID) { + /* def handle_json_GET_triprows(self, params): + """Return a list of rows from the feed file that are related to this + trip.""" + schedule = self.server.schedule + try: + trip = schedule.GetTrip(params.get('trip', None)) + except KeyError: + # if a non-existent trip is searched for, the return nothing + return + route = schedule.GetRoute(trip.route_id) + trip_row = dict(trip.iteritems()) + route_row = dict(route.iteritems()) + return [['trips.txt', trip_row], ['routes.txt', route_row]] + */ +} +function getTripShape() { + /* def handle_json_GET_tripstoptimes(self, params): + schedule = self.server.schedule + try: + trip = schedule.GetTrip(params.get('trip')) + except KeyError: + # if a non-existent trip is searched for, the return nothing + return + time_stops = trip.GetTimeInterpolatedStops() + stops = [] + times = [] + for arr,ts,is_timingpoint in time_stops: + stops.append(StopToTuple(ts.stop)) + times.append(arr) + return [stops, times] + def handle_json_GET_tripshape(self, params): + schedule = self.server.schedule + try: + trip = schedule.GetTrip(params.get('trip')) + except KeyError: + # if a non-existent trip is searched for, the return nothing + return + points = [] + if trip.shape_id: + shape = schedule.GetShape(trip.shape_id) + for (lat, lon, dist) in shape.points: + points.append((lat, lon)) + else: + time_stops = trip.GetTimeStops() + for arr,dep,stop in time_stops: + points.append((stop.stop_lat, stop.stop_lon)) + return points*/ +} +function tripStopTimes($tripID, $after_time, $limit) { + /* rv = [] + + stoptimes = self.GetStopTimes() + # If there are no stoptimes [] is the correct return value but if the start + # or end are missing times there is no correct return value. + if not stoptimes: + return [] + if (stoptimes[0].GetTimeSecs() is None or + stoptimes[-1].GetTimeSecs() is None): + raise ValueError("%s must have time at first and last stop" % (self)) + + cur_timepoint = None + next_timepoint = None + distance_between_timepoints = 0 + distance_traveled_between_timepoints = 0 + + for i, st in enumerate(stoptimes): + if st.GetTimeSecs() != None: + cur_timepoint = st + distance_between_timepoints = 0 + distance_traveled_between_timepoints = 0 + if i + 1 < len(stoptimes): + k = i + 1 + distance_between_timepoints += util.ApproximateDistanceBetweenStops(stoptimes[k-1].stop, stoptimes[k].stop) + while stoptimes[k].GetTimeSecs() == None: + k += 1 + distance_between_timepoints += util.ApproximateDistanceBetweenStops(stoptimes[k-1].stop, stoptimes[k].stop) + next_timepoint = stoptimes[k] + rv.append( (st.GetTimeSecs(), st, True) ) + else: + distance_traveled_between_timepoints += util.ApproximateDistanceBetweenStops(stoptimes[i-1].stop, st.stop) + distance_percent = distance_traveled_between_timepoints / distance_between_timepoints + total_time = next_timepoint.GetTimeSecs() - cur_timepoint.GetTimeSecs() + time_estimate = distance_percent * total_time + cur_timepoint.GetTimeSecs() + rv.append( (int(round(time_estimate)), st, False) ) + + return rv*/ +} + +function tripStartTime($tripID) { + $query = 'SELECT arrival_secs,departure_secs FROM stop_times WHERE trip_id=? ORDER BY stop_sequence LIMIT 1'; + +} + +function viaPoints($tripid, $stopid, $timingPointsOnly = false) +{ + global $APIurl; + $url = $APIurl . "/json/tripstoptimes?trip=" . $tripid; + $json = json_decode(getPage($url)); + debug(print_r($json, true)); + $stops = $json[0]; + $times = $json[1]; + $foundStop = false; + $viaPoints = Array(); + foreach ($stops as $key => $row) { + if ($foundStop) { + if (!$timingPointsOnly || !startsWith($row[5], "Wj")) { + $viaPoints[] = Array( + "id" => $row[0], + "name" => $row[1], + "time" => $times[$key] + ); + } + } + else { + if ($row[0] == $stopid) $foundStop = true; + } + } + return $viaPoints; +} +function viaPointNames($tripid, $stopid) +{ + $points = viaPoints($tripid, $stopid, true); + $pointNames = Array(); + foreach ($points as $point) { + $pointNames[] = $point['name']; + } + return implode(", ", $pointNames); +} +?>
--- a/layar_api.php +++ b/layar_api.php @@ -9,29 +9,29 @@ $page_end = $max_page + filter_var($_REQUEST['pageKey'], FILTER_SANITIZE_NUMBER_INT); $lat = filter_var($_REQUEST['lat'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $lon = filter_var($_REQUEST['lon'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); -$url = $APIurl . "/json/neareststops?lat=$lat&lon=$lon&limit=50"; -$contents = json_decode(getPage($url)); -debug(print_r($contents, true)); + +$contents = getStopsNearby($lat, $lon, 50); + $stopNum = 0; -foreach ($contents as $row) { +foreach ($contents as $stop) { $stopNum++; if ($stopNum > $page_start && $stopNum <= $page_end) { $hotspot = Array(); - $hotspot['id'] = $row[0]; - $hotspot['title'] = $row[1]; + $hotspot['id'] = $stop[id]; + $hotspot['title'] = $stop[name]; $hotspot['type'] = 0; - $hotspot['lat'] = floor($row[2] * 1000000); - $hotspot['lon'] = floor($row[3] * 1000000); - $hotspot['distance'] = distance($row[2], $row[3], $_REQUEST['lat'], $_REQUEST['lon']); + $hotspot['lat'] = floor($stop[lat] * 1000000); + $hotspot['lon'] = floor($stop[lon] * 1000000); + $hotspot['distance'] = distance($stop[lat], $stop[lon], $_REQUEST['lat'], $_REQUEST['lon']); $hotspot['actions'] = Array( Array( "label" => 'View more trips/information', - 'uri' => 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $row[0] + 'uri' => 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $stop[id] ) ); + $url = $APIurl . "/json/stoptrips?stop=" . $row[0] . "&time=" . midnight_seconds() . "&service_period=" . service_period() . "&limit=4&time_range=" . strval(90 * 60); - $trips = json_decode(getPage($url)); - debug(print_r($trips, true)); + $trips = getStopTrips($stopID); foreach ($trips as $key => $row) { if ($key < 3) { $hotspot['line' . strval($key + 2) ] = $row[1][1] . ' @ ' . midnight_seconds_to_time($row[0]);
--- /dev/null +++ b/lib/postgis.sh @@ -1,1 +1,3 @@ +createlang -d dbname plpgsql +psql -d transitdata -f postgis.sql
--- /dev/null +++ b/lib/postgis.sql @@ -1,1 +1,7788 @@ - +-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +-- +-- $Id: postgis.sql.in.c 5385 2010-03-09 00:22:41Z pramsey $ +-- +-- PostGIS - Spatial Types for PostgreSQL +-- http://postgis.refractions.net +-- Copyright 2001-2003 Refractions Research Inc. +-- +-- This is free software; you can redistribute and/or modify it under +-- the terms of the GNU General Public Licence. See the COPYING file. +-- +-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +-- +-- WARNING: Any change in this file must be evaluated for compatibility. +-- Changes cleanly handled by postgis_upgrade.sql are fine, +-- other changes will require a bump in Major version. +-- Currently only function replaceble by CREATE OR REPLACE +-- are cleanly handled. +-- +-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +-- INSTALL VERSION: 1.5.1 + +SET client_min_messages TO warning; + +BEGIN; + +------------------------------------------------------------------- +-- SPHEROID TYPE +------------------------------------------------------------------- + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_spheroid_in(cstring) + RETURNS spheroid + AS '$libdir/postgis-1.5','ellipsoid_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_spheroid_out(spheroid) + RETURNS cstring + AS '$libdir/postgis-1.5','ellipsoid_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION spheroid_in(cstring) + RETURNS spheroid + AS '$libdir/postgis-1.5','ellipsoid_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION spheroid_out(spheroid) + RETURNS cstring + AS '$libdir/postgis-1.5','ellipsoid_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE TYPE spheroid ( + alignment = double, + internallength = 65, + input = spheroid_in, + output = spheroid_out +); + +------------------------------------------------------------------- +-- GEOMETRY TYPE (lwgeom) +------------------------------------------------------------------- + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_geometry_in(cstring) + RETURNS geometry + AS '$libdir/postgis-1.5','LWGEOM_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_geometry_out(geometry) + RETURNS cstring + AS '$libdir/postgis-1.5','LWGEOM_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_geometry_analyze(internal) + RETURNS bool + AS '$libdir/postgis-1.5', 'LWGEOM_analyze' + LANGUAGE 'C' VOLATILE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_geometry_recv(internal) + RETURNS geometry + AS '$libdir/postgis-1.5','LWGEOM_recv' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_geometry_send(geometry) + RETURNS bytea + AS '$libdir/postgis-1.5','LWGEOM_send' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION geometry_in(cstring) + RETURNS geometry + AS '$libdir/postgis-1.5','LWGEOM_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION geometry_out(geometry) + RETURNS cstring + AS '$libdir/postgis-1.5','LWGEOM_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION geometry_analyze(internal) + RETURNS bool + AS '$libdir/postgis-1.5', 'LWGEOM_analyze' + LANGUAGE 'C' VOLATILE STRICT; + +CREATE OR REPLACE FUNCTION geometry_recv(internal) + RETURNS geometry + AS '$libdir/postgis-1.5','LWGEOM_recv' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION geometry_send(geometry) + RETURNS bytea + AS '$libdir/postgis-1.5','LWGEOM_send' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE TYPE geometry ( + internallength = variable, + input = geometry_in, + output = geometry_out, + send = geometry_send, + receive = geometry_recv, + delimiter = ':', + analyze = geometry_analyze, + storage = main +); + +------------------------------------------- +-- Affine transforms +------------------------------------------- + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8) + RETURNS geometry + AS '$libdir/postgis-1.5', 'LWGEOM_affine' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8) + RETURNS geometry + AS '$libdir/postgis-1.5', 'LWGEOM_affine' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Affine(geometry,float8,float8,float8,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Affine(geometry,float8,float8,float8,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION RotateZ(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_RotateZ(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Rotate(geometry,float8) + RETURNS geometry + AS 'SELECT rotateZ($1, $2)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Rotate(geometry,float8) + RETURNS geometry + AS 'SELECT rotateZ($1, $2)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION RotateX(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_RotateX(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.2 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION RotateY(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, cos($2), 0, sin($2), 0, 1, 0, -sin($2), 0, cos($2), 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_RotateY(geometry,float8) + RETURNS geometry + AS 'SELECT affine($1, cos($2), 0, sin($2), 0, 1, 0, -sin($2), 0, cos($2), 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Translate(geometry,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Translate(geometry,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Translate(geometry,float8,float8) + RETURNS geometry + AS 'SELECT translate($1, $2, $3, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Translate(geometry,float8,float8) + RETURNS geometry + AS 'SELECT translate($1, $2, $3, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.0 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Scale(geometry,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Scale(geometry,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.0 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION Scale(geometry,float8,float8) + RETURNS geometry + AS 'SELECT scale($1, $2, $3, 1)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_Scale(geometry,float8,float8) + RETURNS geometry + AS 'SELECT scale($1, $2, $3, 1)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.0 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION transscale(geometry,float8,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $4, 0, 0, 0, $5, 0, + 0, 0, 1, $2 * $4, $3 * $5, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_transscale(geometry,float8,float8,float8,float8) + RETURNS geometry + AS 'SELECT affine($1, $4, 0, 0, 0, $5, 0, + 0, 0, 1, $2 * $4, $3 * $5, 0)' + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 1.1.0 +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION shift_longitude(geometry) + RETURNS geometry + AS '$libdir/postgis-1.5', 'LWGEOM_longitude_shift' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Availability: 1.2.2 +CREATE OR REPLACE FUNCTION ST_shift_longitude(geometry) + RETURNS geometry + AS '$libdir/postgis-1.5', 'LWGEOM_longitude_shift' + LANGUAGE 'C' IMMUTABLE STRICT; + +------------------------------------------------------------------- +-- BOX3D TYPE +------------------------------------------------------------------- + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_box3d_in(cstring) + RETURNS box3d + AS '$libdir/postgis-1.5', 'BOX3D_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Deprecation in 1.5.0 +CREATE OR REPLACE FUNCTION st_box3d_out(box3d) + RETURNS cstring + AS '$libdir/postgis-1.5', 'BOX3D_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION box3d_in(cstring) + RETURNS box3d + AS '$libdir/postgis-1.5', 'BOX3D_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION box3d_out(box3d) + RETURNS cstring + AS '$libdir/postgis-1.5', 'BOX3D_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE TYPE box3d ( + alignment = double, + internallength = 48, + input = box3d_in, + output = box3d_out +); + +-- Temporary box3d aggregate type to retain full double precision +-- for ST_Extent(). Should be removed when we change the output +-- type of ST_Extent() to return something other than BOX2DFLOAT4. +CREATE OR REPLACE FUNCTION box3d_extent_in(cstring) + RETURNS box3d_extent + AS '$libdir/postgis-1.5', 'BOX3D_in' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION box3d_extent_out(box3d_extent) + RETURNS cstring + AS '$libdir/postgis-1.5', 'BOX3D_extent_out' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE TYPE box3d_extent ( + alignment = double, + internallength = 48, + input = box3d_extent_in, + output = box3d_extent_out +); + +-- Availability: 1.4.0 +CREATE OR REPLACE FUNCTION box3d_extent(box3d_extent) + RETURNS box3d + AS '$libdir/postgis-1.5', 'BOX3D_extent_to_BOX3D' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION box2d(box3d_extent) + RETURNS box2d + AS '$libdir/postgis-1.5', 'BOX3D_to_BOX2DFLOAT4' + LANGUAGE 'C' IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION geometry(box3d_extent) + RETURNS geometry + AS '$libdir/postgis-1.5','BOX3D_to_LWGEOM' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- End of temporary hack + +-- Deprecation in 1.2.3 +CREATE OR REPLACE FUNCTION xmin(box3d) + RETURNS FLOAT8 + AS '$libdir/postgis-1.5',&