<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
com.springsource.javax.media.jai.codec,\
com.springsource.javax.media.jai.core,\
org.argeo.dep.osgi.jai.imageio,\
- org.springframework.context
+ org.springframework.context,\
+ org.argeo.slc.unit,\
+ com.springsource.junit,\
+ com.springsource.org.dom4j,\
+ org.springframework.jdbc,\
+ com.springsource.org.postgresql.jdbc3,\
+ com.springsource.javax.transaction,\
+ org.argeo.dep.osgi.postgis.jdbc,\
+ com.springsource.org.apache.commons.collections,\
+ com.springsource.javassist
--- /dev/null
+package org.argeo.slc.gpx;
+
+import java.io.InputStream;
+
+public interface TrackDao {
+ public Object importTrackPoints(String sensor, InputStream in);
+}
--- /dev/null
+package org.argeo.slc.gpx;
+
+import java.util.Date;
+
+import com.vividsolutions.jts.geom.Point;
+
+public class TrackPoint {
+ private Integer tid;
+ private String segmentUuid;
+ private String sensor;
+ private Date utcTimestamp;
+ private Point location;
+ private Double elevation;
+
+ public Integer getTid() {
+ return tid;
+ }
+
+ public void setTid(Integer tid) {
+ this.tid = tid;
+ }
+
+ public String getSegmentUuid() {
+ return segmentUuid;
+ }
+
+ public void setSegmentUuid(String segmentUuid) {
+ this.segmentUuid = segmentUuid;
+ }
+
+ public String getSensor() {
+ return sensor;
+ }
+
+ public void setSensor(String sensor) {
+ this.sensor = sensor;
+ }
+
+ public Date getUtcTimestamp() {
+ return utcTimestamp;
+ }
+
+ public void setUtcTimestamp(Date ts) {
+ this.utcTimestamp = ts;
+ }
+
+ public Point getLocation() {
+ return location;
+ }
+
+ public void setLocation(Point location) {
+ this.location = location;
+ }
+
+ public Double getElevation() {
+ return elevation;
+ }
+
+ public void setElevation(Double elevation) {
+ this.elevation = elevation;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.gpx;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.vividsolutions.jts.geom.LineString;
+
+public class TrackSegment {
+ private Integer tid;
+ private String uuid;
+ private String sensor;
+ private Date startUtc;
+ private Date endUtc;
+ private LineString segment;
+ private List<TrackPoint> trackPoints = new ArrayList<TrackPoint>();
+ private List<TrackSpeed> trackSpeeds = new ArrayList<TrackSpeed>();
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getSensor() {
+ return sensor;
+ }
+
+ public void setSensor(String sensor) {
+ this.sensor = sensor;
+ }
+
+ public List<TrackPoint> getTrackPoints() {
+ return trackPoints;
+ }
+
+ public void setTrackPoints(List<TrackPoint> trackPoints) {
+ this.trackPoints = trackPoints;
+ }
+
+ public Date getStartUtc() {
+ return startUtc;
+ }
+
+ public void setStartUtc(Date start) {
+ this.startUtc = start;
+ }
+
+ public Date getEndUtc() {
+ return endUtc;
+ }
+
+ public void setEndUtc(Date end) {
+ this.endUtc = end;
+ }
+
+ public LineString getSegment() {
+ return segment;
+ }
+
+ public void setSegment(LineString segment) {
+ this.segment = segment;
+ }
+
+ public Integer getTid() {
+ return tid;
+ }
+
+ public void setTid(Integer tid) {
+ this.tid = tid;
+ }
+
+ public List<TrackSpeed> getTrackSpeeds() {
+ return trackSpeeds;
+ }
+
+ public void setTrackSpeeds(List<TrackSpeed> trackSpeeds) {
+ this.trackSpeeds = trackSpeeds;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.gpx;
+
+import java.util.Date;
+
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.Point;
+
+public class TrackSpeed {
+ private Integer tid;
+ private String segmentUuid;
+ private String sensor;
+ private Date utcTimestamp;
+ private Point location;
+ private LineString line;
+ private Double length;
+ private Long duration;
+ // length(line)/(duration in h)
+ private Double speed;
+ // can be null
+ private Double acceleration;
+
+ public TrackSpeed() {
+ }
+
+ public TrackSpeed(TrackPoint ref, LineString line, Long duration) {
+ segmentUuid = ref.getSegmentUuid();
+ sensor = ref.getSensor();
+ utcTimestamp = ref.getUtcTimestamp();
+ location = ref.getLocation();
+ this.line = line;
+ this.duration = duration;
+
+ this.length = Math.abs(line.getLength());
+ // in km/h
+ this.speed = (this.length * 60 * 60) / this.duration;
+ }
+
+ public Integer getTid() {
+ return tid;
+ }
+
+ public void setTid(Integer tid) {
+ this.tid = tid;
+ }
+
+ public String getSegmentUuid() {
+ return segmentUuid;
+ }
+
+ public void setSegmentUuid(String segmentUuid) {
+ this.segmentUuid = segmentUuid;
+ }
+
+ public String getSensor() {
+ return sensor;
+ }
+
+ public void setSensor(String sensor) {
+ this.sensor = sensor;
+ }
+
+ public Date getUtcTimestamp() {
+ return utcTimestamp;
+ }
+
+ public void setUtcTimestamp(Date ts) {
+ this.utcTimestamp = ts;
+ }
+
+ public Point getLocation() {
+ return location;
+ }
+
+ public void setLocation(Point location) {
+ this.location = location;
+ }
+
+ public LineString getLine() {
+ return line;
+ }
+
+ public void setLine(LineString line) {
+ this.line = line;
+ }
+
+ public Long getDuration() {
+ return duration;
+ }
+
+ public void setDuration(Long duration) {
+ this.duration = duration;
+ }
+
+ public Double getSpeed() {
+ return speed;
+ }
+
+ public void setSpeed(Double speed) {
+ this.speed = speed;
+ }
+
+ public Double getLength() {
+ return length;
+ }
+
+ public void setLength(Double length) {
+ this.length = length;
+ }
+
+ public Double getAcceleration() {
+ return acceleration;
+ }
+
+ public void setAcceleration(Double acceleration) {
+ this.acceleration = acceleration;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.gpx.hibernate;
+
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.slc.gpx.TrackDao;
+import org.argeo.slc.gpx.TrackPoint;
+import org.argeo.slc.gpx.TrackSegment;
+import org.argeo.slc.gpx.TrackSpeed;
+import org.geotools.geometry.DirectPosition2D;
+import org.geotools.referencing.CRS;
+import org.opengis.geometry.DirectPosition;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.geom.PrecisionModel;
+
+public class HibernateTrackDao extends HibernateDaoSupport implements TrackDao {
+ private final static Log log = LogFactory.getLog(HibernateTrackDao.class);
+ private final static DateFormat ISO8601 = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ss");
+
+ private Long batchSize = 100l;
+ private Integer targetSrid = 4326;
+ private Float maxSpeed = 250f;
+
+ public Object importTrackPoints(String sensor, InputStream in) {
+ long begin = System.currentTimeMillis();
+ try {
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setValidating(false);
+ SAXParser sp = spf.newSAXParser();
+ InputSource input = new InputSource(in);
+ TrackGpxHandler handler = new TrackGpxHandler(sensor, targetSrid);
+ sp.parse(input, handler);
+ return null;
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot parse GPX stream", e);
+ } finally {
+ long duration = System.currentTimeMillis() - begin;
+ if (log.isDebugEnabled())
+ log.debug("Imported from sensor '" + sensor + "' in "
+ + (duration) + " ms");
+ }
+ }
+
+ protected void processTrackSegment(TrackSegment trackSegment,
+ GeometryFactory geometryFactory) {
+ TrackSpeed currentTrackSpeed = null;
+ List<Coordinate> coords = new ArrayList<Coordinate>();
+ trackPoints: for (int i = 0; i < trackSegment.getTrackPoints().size(); i++) {
+ TrackPoint trackPoint = trackSegment.getTrackPoints().get(i);
+ coords.add(new Coordinate(trackPoint.getLocation().getX(),
+ trackPoint.getLocation().getY()));
+
+ if (i == 0)
+ trackSegment.setStartUtc(trackPoint.getUtcTimestamp());
+
+ if (i == trackSegment.getTrackPoints().size() - 1)
+ trackSegment.setEndUtc(trackPoint.getUtcTimestamp());
+ else {
+ // SPEED
+ TrackPoint next = trackSegment.getTrackPoints().get(i + 1);
+
+ Coordinate[] crds = { trackPoint.getLocation().getCoordinate(),
+ next.getLocation().getCoordinate() };
+ LineString line = geometryFactory.createLineString(crds);
+ Long duration = next.getUtcTimestamp().getTime()
+ - trackPoint.getUtcTimestamp().getTime();
+ if (duration < 0) {
+ log.warn("Duration " + duration + " is negative between "
+ + trackPoint.getLocation() + " and "
+ + next.getLocation()
+ + ", skipping speed computation");
+ currentTrackSpeed = null;
+ continue trackPoints;
+ }
+ TrackSpeed trackSpeed = new TrackSpeed(trackPoint, line,
+ duration);
+ if (trackSpeed.getSpeed() > maxSpeed) {
+ log.warn("Speed " + trackSpeed.getSpeed() + " is above "
+ + maxSpeed + " between " + trackPoint.getLocation()
+ + " and " + next.getLocation()
+ + ", skipping speed computation");
+ currentTrackSpeed = null;
+ continue trackPoints;
+ }
+
+ if (currentTrackSpeed != null) {
+ // in m/s²
+ Double speed1 = trackSpeed.getLength()
+ / (trackSpeed.getDuration() / 1000);
+ Double speed2 = currentTrackSpeed.getLength()
+ / (currentTrackSpeed.getDuration() / 1000);
+ Double acceleration = (speed1 - speed2)
+ / (currentTrackSpeed.getDuration() / 1000);
+ trackSpeed.setAcceleration(acceleration);
+ }
+ trackSegment.getTrackSpeeds().add(trackSpeed);
+ currentTrackSpeed = trackSpeed;
+ }
+
+ }
+ LineString segment = geometryFactory.createLineString(coords
+ .toArray(new Coordinate[coords.size()]));
+ trackSegment.setSegment(segment);
+
+ }
+
+ public void setBatchSize(Long batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public void setTargetSrid(Integer targetSrid) {
+ this.targetSrid = targetSrid;
+ }
+
+ public void setMaxSpeed(Float maxSpeed) {
+ this.maxSpeed = maxSpeed;
+ }
+
+ class TrackGpxHandler extends DefaultHandler {
+ private final CoordinateReferenceSystem wgs84;
+ private final GeometryFactory targetGF;
+
+ private final MathTransform reprojection;
+
+ public static final String TAG_TRKSEG = "trkseg";
+ public static final String TAG_TRKPT = "trkpt";
+ public static final String TAG_TIME = "time";
+ public static final String TAG_ELE = "ele";
+ public static final String ATTR_LAT = "lat";
+ public static final String ATTR_LON = "lon";
+
+ private String sensor;
+
+ private StringBuffer accumulator = new StringBuffer();
+
+ private Long segmentCount = 0l;
+ private Long pointCount = 0l;
+ private Long currentSegmentPointCount = 0l;
+ private String currentSegmentUuid = null;
+ private TrackPoint currentTrackPoint = null;
+
+ private TrackSegment currentTrackSegment = null;
+
+ private List<TrackPoint> trackPoints = new ArrayList<TrackPoint>();
+
+ public TrackGpxHandler(String sensor, Integer srid) {
+ this.sensor = sensor;
+ PrecisionModel precisionModel = new PrecisionModel();
+ targetGF = new GeometryFactory(precisionModel, srid);
+ if (srid != 4326) {
+ try {
+ wgs84 = CRS.decode("EPSG:4326");
+ reprojection = CRS.findMathTransform(wgs84,
+ CRS.decode("EPSG:" + srid));
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot find reprojection", e);
+ }
+ } else {
+ reprojection = null;
+ wgs84 = null;
+ }
+ }
+
+ public void characters(char[] buffer, int start, int length) {
+ accumulator.append(buffer, start, length);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
+ // log.debug("Element: localName=" + localName + ", uri=" + uri
+ // + ", qName=" + qName);
+
+ accumulator.setLength(0); // Ready to accumulate new text
+ if (qName.equals(TAG_TRKSEG)) {
+ currentSegmentUuid = UUID.randomUUID().toString();
+ currentTrackSegment = new TrackSegment();
+ currentTrackSegment.setSensor(sensor);
+ currentTrackSegment.setUuid(currentSegmentUuid);
+ } else if (qName.equals(TAG_TRKPT)) {
+ currentTrackPoint = new TrackPoint();
+ currentTrackPoint.setSensor(sensor);
+ currentTrackPoint.setSegmentUuid(currentSegmentUuid);
+ String latStr = attributes.getValue(ATTR_LAT);
+ String lonStr = attributes.getValue(ATTR_LON);
+ Coordinate coordinate = new Coordinate(
+ Double.parseDouble(lonStr), Double.parseDouble(latStr));
+ Point location = reproject(coordinate);
+ currentTrackPoint.setLocation(location);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+ // if (log.isDebugEnabled())
+ // log.debug("TAG " + qName);
+ if (qName.equals(TAG_TRKSEG)) {
+ // if (log.isDebugEnabled())
+ // log.debug("Processed segment " + currentSegmentUuid + ": "
+ // + currentSegmentPointCount + " points");
+
+ if (currentTrackSegment.getTrackPoints().size() > 1) {
+ processTrackSegment(currentTrackSegment, targetGF);
+
+ // persist
+ getHibernateTemplate().save(currentTrackSegment);
+ segmentCount++;
+ if (segmentCount % batchSize == 0) {
+ getHibernateTemplate().flush();
+ getHibernateTemplate().clear();
+ }
+ } else if (currentTrackSegment.getTrackPoints().size() == 1) {
+ TrackPoint trackPoint = currentTrackSegment
+ .getTrackPoints().get(0);
+ getHibernateTemplate().save(trackPoint);
+ }
+ currentSegmentPointCount = 0l;
+ currentSegmentUuid = null;
+ } else if (qName.equals(TAG_TRKPT)) {
+ trackPoints.add(currentTrackPoint);
+ pointCount++;
+ currentSegmentPointCount++;
+
+ currentTrackSegment.getTrackPoints().add(currentTrackPoint);
+
+ // getHibernateTemplate().save(currentTrackPoint);
+
+ currentTrackPoint = null;
+ } else if (qName.equals(TAG_ELE)) {
+ Double elevation = Double.parseDouble(accumulator.toString()
+ .trim());
+ currentTrackPoint.setElevation(elevation);
+ } else if (qName.equals(TAG_TIME) && currentTrackPoint != null) {
+ String timeStr = accumulator.toString().trim();
+ try {
+ Date time = ISO8601.parse(timeStr);
+ currentTrackPoint.setUtcTimestamp(time);
+ } catch (ParseException e) {
+ throw new ArgeoException("Cannot parse date " + timeStr);
+ }
+ }
+
+ }
+
+ protected Point reproject(Coordinate coordinate) {
+ if (reprojection != null) {
+ try {
+ // invert order
+ DirectPosition2D pos = new DirectPosition2D(wgs84,
+ coordinate.y, coordinate.x);
+ DirectPosition targetPos = reprojection
+ .transform(pos, null);
+ Coordinate targetCoordinate = new Coordinate(
+ targetPos.getOrdinate(0), targetPos.getOrdinate(1));
+ return targetGF.createPoint(targetCoordinate);
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot reproject " + coordinate,
+ e);
+ }
+ } else {
+ return targetGF.createPoint(coordinate);
+ }
+ }
+ }
+
+}
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.argeo.slc.gpx">
+ <class name="TrackPoint" table="TRACK_POINTS">
+ <!-- <cache usage="read-write" /> -->
+ <id name="tid" column="TID" type="integer">
+ <generator class="increment" />
+ </id>
+ <property name="location" type="org.hibernatespatial.GeometryUserType">
+ <column name="LOCATION" />
+ </property>
+ <property name="sensor" column="SENSOR" />
+ <property name="segmentUuid" column="SEGMENT_UUID" />
+ <property name="elevation" column="ELEVATION" />
+ <property name="utcTimestamp" column="UTC_TIMESTAMP" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.argeo.slc.gpx">
+ <class name="TrackSegment" table="TRACK_SEGMENTS">
+ <!-- <cache usage="read-write" /> -->
+ <id name="tid" column="TID" type="integer">
+ <generator class="increment" />
+ </id>
+ <property name="segment" type="org.hibernatespatial.GeometryUserType">
+ <column name="SEGMENT" />
+ </property>
+ <property name="uuid" column="UUID" />
+ <property name="sensor" column="SENSOR" />
+ <property name="startUtc" column="START_UTC" />
+ <property name="endUtc" column="END_UTC" />
+ <list name="trackPoints" cascade="all" table="TRACK_SEGMENTS_POINTS"
+ lazy="true">
+ <key column="SEGMENT_ID" />
+ <list-index column="INDX" />
+ <many-to-many class="TrackPoint" column="TRACK_POINT_ID"
+ unique="true" />
+ </list>
+ <list name="trackSpeeds" cascade="all" table="TRACK_SEGMENTS_SPEEDS"
+ lazy="true">
+ <key column="SEGMENT_ID" />
+ <list-index column="INDX" />
+ <many-to-many class="TrackSpeed" column="TRACK_SPEED_ID"
+ unique="true" />
+ </list>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.argeo.slc.gpx">
+ <class name="TrackSpeed" table="TRACK_SPEEDS">
+ <!-- <cache usage="read-write" /> -->
+ <id name="tid" column="TID" type="integer">
+ <generator class="increment" />
+ </id>
+ <property name="location" type="org.hibernatespatial.GeometryUserType">
+ <column name="LOCATION" />
+ </property>
+ <property name="line" type="org.hibernatespatial.GeometryUserType">
+ <column name="LINE" />
+ </property>
+ <property name="sensor" column="SENSOR" />
+ <property name="segmentUuid" column="SEGMENT_UUID" />
+ <property name="duration" column="DURATION" />
+ <property name="length" column="LENGTH" />
+ <property name="speed" column="SPEED" />
+ <property name="acceleration" column="ACCELERATION" not-null="false" />
+ <property name="utcTimestamp" column="UTC_TIMESTAMP" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.argeo.slc.gpx.hibernate;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+\r
+import org.apache.commons.io.IOUtils;\r
+import org.argeo.slc.gpx.TrackDao;\r
+import org.argeo.slc.hibernate.unit.HibernateTestCase;\r
+import org.hibernatespatial.HBSpatialExtension;\r
+import org.hibernatespatial.cfg.HSConfiguration;\r
+\r
+public class HibernateTrackDaoTestCase extends HibernateTestCase {\r
+ static {\r
+ HSConfiguration config = new HSConfiguration();\r
+ config.setDefaultDialect("org.hibernatespatial.postgis.PostgisDialect");\r
+ \r
+ HBSpatialExtension.setConfiguration(config);\r
+ }\r
+\r
+ public void testImport() throws Exception {\r
+ String sensor = "mbaudier";\r
+ File dir = new File("/home/mbaudier/ArgeoOffice/perso/gps/trips/2010");\r
+\r
+ TrackDao trackDao = getBean(TrackDao.class);\r
+ long begin = System.currentTimeMillis();\r
+ for (File file : dir.listFiles()) {\r
+ if (!file.getName().endsWith(".gpx"))\r
+ continue;\r
+ FileInputStream in = null;\r
+ try {\r
+ in = new FileInputStream(file);\r
+ trackDao.importTrackPoints(sensor, in);\r
+ } catch (Exception e) {\r
+ log.warn("Could not import " + file + ": " + e.getMessage());\r
+ throw e;\r
+ } finally {\r
+ IOUtils.closeQuietly(in);\r
+ }\r
+ }\r
+ double duration = System.currentTimeMillis() - begin;\r
+ if (log.isDebugEnabled())\r
+ log.debug("Imported files from " + dir + " in "\r
+ + (duration / 1000 / 60) + " min");\r
+ }\r
+}\r
# Slc\r
log4j.logger.org.argeo=DEBUG\r
\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
+# Hibernate\r
+log4j.logger.org.hibernate=WARN\r
+log4j.logger.org.hibernatespatial=WARN\r
\r
# Spring\r
log4j.logger.org.springframework=WARN\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <bean id="sessionFactory"\r
+ class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">\r
+ <property name="dataSource" ref="dataSource" />\r
+ <property name="hibernateProperties">\r
+ <value><![CDATA[\r
+hibernate.dialect=org.hibernatespatial.postgis.PostgisDialect\r
+hibernate.hbm2ddl.auto=create\r
+hibernate.current_session_context_class=thread\r
+hibernate.jdbc.batch_size=100\r
+ ]]></value>\r
+ </property>\r
+ <property name="mappingResources">\r
+ <list>\r
+ <value>org/argeo/slc/gpx/hibernate/TrackPoint.hbm.xml</value>\r
+ <value>org/argeo/slc/gpx/hibernate/TrackSegment.hbm.xml</value>\r
+ <value>org/argeo/slc/gpx/hibernate/TrackSpeed.hbm.xml</value>\r
+ </list>\r
+ </property>\r
+ </bean>\r
+\r
+ <!-- <bean id="dataSource" -->\r
+ <!-- class="org.springframework.jdbc.datasource.SingleConnectionDataSource" -->\r
+ <!-- destroy-method="destroy" lazy-init="true"> -->\r
+ <!-- <property name="driverClassName" value="org.h2.Driver" /> -->\r
+ <!-- <property name="url" value="jdbc:h2:mem:test" /> -->\r
+ <!-- <property name="username" value="sa" /> -->\r
+ <!-- <property name="password" value="" /> -->\r
+ <!-- <property name="suppressClose" value="true" /> -->\r
+ <!-- </bean> -->\r
+\r
+ <bean id="dataSource"\r
+ class="org.springframework.jdbc.datasource.SingleConnectionDataSource"\r
+ destroy-method="destroy" lazy-init="true">\r
+ <property name="driverClassName" value="org.postgresql.Driver" />\r
+ <property name="url" value="jdbc:postgresql://air/test_berlin" />\r
+ <property name="username" value="argeo" />\r
+ <property name="password" value="argeo" />\r
+ <property name="suppressClose" value="true" />\r
+ </bean>\r
+\r
+ <bean id="trackDao" class="org.argeo.slc.gpx.hibernate.HibernateTrackDao">\r
+ <property name="sessionFactory" ref="sessionFactory" />\r
+ <property name="batchSize" value="100" />\r
+ <property name="targetSrid" value="3857" />\r
+ </bean>\r
+</beans>
\ No newline at end of file