Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from EHJ-52n/develop
Browse files Browse the repository at this point in the history
Merge with latest developments from EHJ-52n
  • Loading branch information
EHJ-52n committed Nov 19, 2013
2 parents 36078f8 + 0f0279d commit 56514ab
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 884 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Thu Aug 04 23:13:17 CEST 2011
wms_url=http\://osmtud.dyndns.org/wms/wms/
wms_layer=OSMBackground
#wms_url=http\://osmtud.dyndns.org/wms/wms/
#wms_layer=OSMBackground
wms_url=http\://129.206.228.72/cached/osm
wms_layer=OSM WMS - osm-wms.de
5 changes: 5 additions & 0 deletions 52n-sos-importer-feeder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,131 +1,148 @@
/**
* Copyright (C) 2012
* by 52North Initiative for Geospatial Open Source Software GmbH
*
* Contact: Andreas Wytzisk
* 52 North Initiative for Geospatial Open Source Software GmbH
* Martin-Luther-King-Weg 24
* 48155 Muenster, Germany
* info@52north.org
*
* This program is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed WITHOUT ANY WARRANTY; even without the implied
* WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program (see gnu-gpl v2.txt). If not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
* visit the Free Software Foundation web page, http://www.fsf.org.
*/
package org.n52.sos.importer.feeder.model;

/**
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk J&uuml;rrens</a>
*/
public class Timestamp {

private short year = Short.MIN_VALUE;
private byte month = Byte.MIN_VALUE;
private byte day = Byte.MIN_VALUE;
private byte hour = Byte.MIN_VALUE;
private byte minute = Byte.MIN_VALUE;
private byte seconds = Byte.MIN_VALUE;
private byte timezone = Byte.MIN_VALUE;



@Override
public String toString() {
StringBuffer ts = new StringBuffer(25); // <- yyyy-mm-ddThh:mm:ss+hh:mm
if (year != Short.MIN_VALUE) {
ts.append(year);
if (month != Byte.MIN_VALUE) {
ts.append("-");
}
}
if (month != Byte.MIN_VALUE) {
ts.append(month<10?"0"+month:month);
if (day != Byte.MIN_VALUE) {
ts.append("-");
}
}
if (day != Byte.MIN_VALUE) {
ts.append(day<10?"0"+day:day);
}
if ( (year != Short.MIN_VALUE || month != Byte.MIN_VALUE || day != Byte.MIN_VALUE )
&& (hour != Byte.MIN_VALUE || minute != Byte.MIN_VALUE || seconds != Byte.MIN_VALUE)) {
ts.append("T");
}
if (hour != Byte.MIN_VALUE) {
ts.append(hour<10?"0"+hour:hour);
if (minute != Byte.MIN_VALUE) {
ts.append(":");
}
}
if (minute != Byte.MIN_VALUE) {
ts.append( (minute<10?"0"+minute:minute)+":");
} else if (hour != Byte.MIN_VALUE) {
ts.append("00:");
}
if (seconds != Byte.MIN_VALUE ) {
ts.append(seconds<10?"0"+seconds:seconds);
} else if (minute != Byte.MIN_VALUE && hour != Byte.MIN_VALUE) {
ts.append("00");
}
if (timezone != Byte.MIN_VALUE &&
(hour != Byte.MIN_VALUE || minute != Byte.MIN_VALUE || seconds != Byte.MIN_VALUE)) {
ts.append(convertTimeZone(timezone));
}

return ts.toString();
}

private String convertTimeZone(int timeZone) {
if (timeZone >= 0) {
if (timeZone >= 10) {
return "+" + timeZone + ":00";
} else {
return "+0" + timeZone + ":00";
}
} else {
if (timeZone <= -10) {
return timeZone + ":00";
} else {
return "-0" + Math.abs(timeZone) + ":00";
}
}
}

public void setYear(short year) {
this.year = year;
}

public void setMonth(byte month) {
this.month = month;
}

public void setDay(byte day) {
this.day = day;
}

public void setHour(byte hour) {
this.hour = hour;
}

public void setMinute(byte minute) {
this.minute = minute;
}

public void setSeconds(byte seconds) {
this.seconds = seconds;
}

public void setTimezone(byte timezone) {
this.timezone = timezone;
}

}
/**
* Copyright (C) 2012
* by 52North Initiative for Geospatial Open Source Software GmbH
*
* Contact: Andreas Wytzisk
* 52 North Initiative for Geospatial Open Source Software GmbH
* Martin-Luther-King-Weg 24
* 48155 Muenster, Germany
* info@52north.org
*
* This program is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed WITHOUT ANY WARRANTY; even without the implied
* WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program (see gnu-gpl v2.txt). If not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
* visit the Free Software Foundation web page, http://www.fsf.org.
*/
package org.n52.sos.importer.feeder.model;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk J&uuml;rrens</a>
*/
public class Timestamp {

private short year = Short.MIN_VALUE;
private byte month = Byte.MIN_VALUE;
private byte day = Byte.MIN_VALUE;
private byte hour = Byte.MIN_VALUE;
private byte minute = Byte.MIN_VALUE;
private byte seconds = Byte.MIN_VALUE;
private byte timezone = Byte.MIN_VALUE;



@Override
public String toString() {
final StringBuffer ts = new StringBuffer(25); // <- yyyy-mm-ddThh:mm:ss+hh:mm
if (year != Short.MIN_VALUE) {
ts.append(year);
if (month != Byte.MIN_VALUE) {
ts.append("-");
}
}
if (month != Byte.MIN_VALUE) {
ts.append(month<10?"0"+month:month);
if (day != Byte.MIN_VALUE) {
ts.append("-");
}
}
if (day != Byte.MIN_VALUE) {
ts.append(day<10?"0"+day:day);
}
if ( (year != Short.MIN_VALUE || month != Byte.MIN_VALUE || day != Byte.MIN_VALUE )
&& (hour != Byte.MIN_VALUE || minute != Byte.MIN_VALUE || seconds != Byte.MIN_VALUE)) {
ts.append("T");
}
if (hour != Byte.MIN_VALUE) {
ts.append(hour<10?"0"+hour:hour);
if (minute != Byte.MIN_VALUE) {
ts.append(":");
}
}
if (minute != Byte.MIN_VALUE) {
ts.append( (minute<10?"0"+minute:minute)+":");
} else if (hour != Byte.MIN_VALUE) {
ts.append("00:");
}
if (seconds != Byte.MIN_VALUE ) {
ts.append(seconds<10?"0"+seconds:seconds);
} else if (minute != Byte.MIN_VALUE && hour != Byte.MIN_VALUE) {
ts.append("00");
}
if (timezone != Byte.MIN_VALUE &&
(hour != Byte.MIN_VALUE || minute != Byte.MIN_VALUE || seconds != Byte.MIN_VALUE)) {
ts.append(convertTimeZone(timezone));
}

return ts.toString();
}

private String convertTimeZone(final int timeZone) {
if (timeZone >= 0) {
if (timeZone >= 10) {
return "+" + timeZone + ":00";
} else {
return "+0" + timeZone + ":00";
}
} else {
if (timeZone <= -10) {
return timeZone + ":00";
} else {
return "-0" + Math.abs(timeZone) + ":00";
}
}
}

public void setYear(final short year) {
this.year = year;
}

public void setMonth(final byte month) {
this.month = month;
}

public void setDay(final byte day) {
this.day = day;
}

public void setHour(final byte hour) {
this.hour = hour;
}

public void setMinute(final byte minute) {
this.minute = minute;
}

public void setSeconds(final byte seconds) {
this.seconds = seconds;
}

public void setTimezone(final byte timezone) {
this.timezone = timezone;
}

public Timestamp set(final long dateToSet)
{
final Calendar cal = new GregorianCalendar();
cal.setTimeInMillis(dateToSet);
year = (short) cal.get(Calendar.YEAR);
month = (byte) (cal.get(Calendar.MONTH)+1);
day = (byte) cal.get(Calendar.DAY_OF_MONTH);
hour = (byte) cal.get(Calendar.HOUR_OF_DAY);
minute = (byte) cal.get(Calendar.MINUTE);
seconds = (byte) cal.get(Calendar.SECOND);
timezone = (byte) (cal.getTimeZone().getOffset(dateToSet)/3600000);
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,31 @@
import org.apache.xmlbeans.XmlException;
import org.n52.oxf.sos.adapter.wrapper.builder.SensorDescriptionBuilder;
import org.n52.sos.importer.feeder.model.ObservedProperty;
import org.n52.sos.importer.feeder.model.Timestamp;
import org.n52.sos.importer.feeder.model.requests.RegisterSensor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DescriptionBuilder {

private final boolean shouldAddOfferingMetadataToOutputs;

public DescriptionBuilder(final boolean shouldAddOfferingMetadataToOutputs) {
this.shouldAddOfferingMetadataToOutputs = shouldAddOfferingMetadataToOutputs;
}

public DescriptionBuilder() {
this(true);
}

private static final Logger LOG = LoggerFactory.getLogger(DescriptionBuilder.class);

public String createSML(final RegisterSensor rs) throws XmlException, IOException {
LOG.trace("createSML()");
final SensorDescriptionBuilder builder = new SensorDescriptionBuilder();

builder.setAddOfferingMetadataToOutputs(shouldAddOfferingMetadataToOutputs);

final StringBuilder intendedApplication = new StringBuilder();

// add keywords
Expand All @@ -67,7 +80,7 @@ public String createSML(final RegisterSensor rs) throws XmlException, IOExceptio
Integer.toString(4326):
rs.getEpsgCode());

builder.addCapability("offerings",rs.getOfferingName(),"urn:ogc:def:identifier:OGC:offeringID",rs.getOfferingUri());
builder.addCapability("offerings",rs.getOfferingName(),"urn:ogc:def:identifier:OGC:1.0:offeringID",rs.getOfferingUri());

// set position data
builder.setPosition("sensorPosition",
Expand Down Expand Up @@ -115,6 +128,9 @@ else if (rs.getMeasuredValueType(observedProperty).equals(SOS_OBSERVATION_TYPE_C
// add all classifier
builder.setClassifierIntendedApplication(intendedApplication.substring(0, intendedApplication.length()-2));

// add validTime starting from now
builder.setValidTime(new Timestamp().set(System.currentTimeMillis()).toString(),"unknown");

return builder.buildSensorDescription();
}

Expand Down
Loading

0 comments on commit 56514ab

Please sign in to comment.