Commit 69c3b7a2 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added autogenerated Version.java to gms-database

parent 434f417e
......@@ -6,6 +6,19 @@
<version>0.0.1</version>
<name>gms-database</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<generatedSources.path>generated-sources/java</generatedSources.path>
<generatedSources.folder>${project.build.directory}/${generatedSources.path}</generatedSources.folder>
<version.template.file>src/main/resources/Version.java.template</version.template.file>
<version.file.path>/de/potsdam/gfz/gms/database/Version.java</version.file.path>
<version.file>${generatedSources.folder}${version.file.path}</version.file>
</properties>
<build>
<resources>
<resource>
......@@ -15,12 +28,12 @@
<include>**/*.xml</include>
</includes>
</resource>
<!-- <resource> -->
<!-- <directory>src/main/resources</directory> -->
<!-- <excludes> -->
<!-- <exclude>*.properties</exclude> -->
<!-- </excludes> -->
<!-- </resource> -->
<!-- <resource> -->
<!-- <directory>src/main/resources</directory> -->
<!-- <excludes> -->
<!-- <exclude>*.properties</exclude> -->
<!-- </excludes> -->
<!-- </resource> -->
</resources>
......@@ -33,25 +46,126 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-surefire-plugin</artifactId> -->
<!-- <version>2.18.1</version> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-jar-plugin</artifactId> -->
<!-- <version>3.0.2</version> -->
<!-- <configuration> -->
<!-- <excludes> -->
<!-- <exclude>**/*.properties</exclude> -->
<!-- </excludes> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${generatedSources.folder}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Buildnumber plugin extracting the git buildnumber and build-timestamp,
needs SCM to be set -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Generates the Version.java file and replacing the buildnumber with
the current git buildnumber extracted by the buildnumber-maven-plugin -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${version.template.file}</file>
<outputFile>${version.file}</outputFile>
<replacements>
<replacement>
<token>@buildnumber@</token>
<value>${buildNumber}</value>
</replacement>
<replacement>
<token>@buildtime@</token>
<value>${timestamp}</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
<!-- Tells the eclipse maven addon to include the replace goal in its lifecycle -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>create</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>replace</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<scm>
<connection>scm:git:git://gitext.gfz-potsdam.de:geomultisens/gms-aux.git</connection>
</scm>
<repositories>
<repository>
<id>n52-releases</id>
......
......@@ -182,32 +182,6 @@ public class SpatialSceneIndex implements SceneIndex {
LOG.info("finished building index");
}
// private static final double PI_QUARTER = 0.25 * PI;
//
// public static double latToY(double lat) {
// return PI - Math.log(Math.tan(PI_QUARTER + 0.5 * Math.toRadians(lat)));
// }
//
// public static double lonToX(double lon) {
// return PI + Math.toRadians(lon);
// }
//
// /**
// * Projects the internal coordinates of the given point from geographical to Cartesian coordinates
// *
// * @param p
// */
// public static Point latLonPointToXY(Point p) {
// p.x = lonToX(p.x);
// p.y = latToY(p.y);
// return p;
// }
//
// public static Envelope latLonEnvelopeToXY(Envelope e) {
// e.init(lonToX(e.getMinX()), lonToX(e.getMaxX()), latToY(e.getMinY()), latToY(e.getMaxY()));
// return e;
// }
public void visit(double x1, double x2, double y1, double y2, SceneVisitor visitor) {
visit(new Envelope(x1, x2, y1, y2), visitor);
}
......
......@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import com.vividsolutions.jts.geom.Envelope;
import de.potsdam.gfz.gms.database.Version;
import de.potsdam.gfz.gms.database.shared.Timestamp;
/**
......@@ -89,7 +90,8 @@ public class SpatialIndexMediator {
unlockChannel();
}
public void countScenesGroupedByDatasets(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte maxCloudcover, byte minProclevel, ByteBuffer buf) {
public void countScenesGroupedByDatasets(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte maxCloudcover, byte minProclevel,
ByteBuffer buf) {
try {
lockChannel();
......@@ -133,6 +135,35 @@ public class SpatialIndexMediator {
unlockChannel();
}
public String getServerVersionInfo() {
String versionInfo = "";
try {
lockChannel();
// send get version msg indicator
out.writeByte(MediatorConstants.GET_VERSION_MSG);
// force sending
out.flush();
// wait for and receive response
if (MediatorConstants.GET_VERSION_MSG == in.read()) {
// get version info string
versionInfo = in.readUTF();
} else {
unlockChannel();
throw new RuntimeException("Get version message send, but different response received!");
}
} catch (Exception e1) {
LOG.error("[getServerVersionInfo]", e1);
}
unlockChannel();
return versionInfo;
}
/**
* @param e
* @param start
......@@ -140,8 +171,8 @@ public class SpatialIndexMediator {
* @param datasetid
* @param buffer
*/
public void getFullSceneDataForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid, byte minProclevel,
byte maxProclevel, ByteBuffer buf) {
public void getFullSceneDataForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid,
byte minProclevel, byte maxProclevel, ByteBuffer buf) {
try {
lockChannel();
......@@ -208,8 +239,8 @@ public class SpatialIndexMediator {
* @param datasetid
* @param buffer
*/
public void getSceneMetaDataForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid, byte minProclevel,
byte maxProclevel, ByteBuffer buf) {
public void getSceneMetaDataForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid,
byte minProclevel, byte maxProclevel, ByteBuffer buf) {
try {
lockChannel();
......@@ -276,8 +307,8 @@ public class SpatialIndexMediator {
* @param datasetid
* @param buffer
*/
public void getSceneBoundsForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid, byte minProclevel,
byte maxProclevel, ByteBuffer buf) {
public void getSceneBoundsForDataset(Envelope e, Timestamp start, Timestamp end, int seasonCode, byte minCloudcover, byte maxCloudcover, short datasetid,
byte minProclevel, byte maxProclevel, ByteBuffer buf) {
try {
lockChannel();
......@@ -351,74 +382,78 @@ public class SpatialIndexMediator {
// public Map<Short, List<Integer>> getScenesGroupedByDatasets(Envelope e, Timestamp start, Timestamp end);
public static void main(String[] args) {
SpatialIndexMediator indexMediator = SpatialIndexMediator.connect("geoms", MediatorConstants.PORT);
// ByteBuffer buf = ByteBuffer.allocate(1000000);
ByteBuffer buf = ByteBuffer.allocate(100000000);
double low = 42.372196452589;
double left = 6.1190697187496;
double up = 55.613615264148;
double right = 17.237233781249;
double[] roi = new double[] { left, low, right, low, right, up, left, up, left, low };
Envelope e = new Envelope();
for (int i = 0; i < roi.length; i += 2) {
e.expandToInclude(roi[i], roi[i + 1]);
}
Timestamp start = new Timestamp(1900, 1, 1);
Timestamp end = Timestamp.now();
// indexMediator.countScenesGroupedByDatasets(e, start, end, buf);
//
// buf.flip();
// short num = buf.getShort();
// for (int i = 0; i < num; ++i) {
// short dataset = buf.getShort();
// int count = buf.getInt();
// indexMediator.getScenesForDataset(e, start, end, dataset, buf2);
// buf2.flip();
// short dataset2 = buf2.getShort();
// int count2 = buf2.getInt();
// LOG.info("datasets: " + dataset + " vs. " + dataset2);
// LOG.info("counts: " + count + " vs. " + count2);
//
// for (int k = 0; k < count2; ++k) {
// int sceneid = buf2.getInt();
// long ts = buf2.getLong();
// byte numBounds = buf2.get();
// double[] bounds = new double[numBounds];
// for (byte j = 0; j < numBounds; ++j) {
// bounds[j] = buf2.getDouble();
// }
//
// System.out.println(sceneid + "|" + new Timestamp(ts).toDateString() + "|" + numBounds + "|" + Arrays.toString(bounds));
// }
// buf2.clear();
// }
indexMediator.getFullSceneDataForDataset(e, start, end, 0, (byte) 0, (byte) 100, (short) 108, (byte) 0, (byte) 100, buf);
buf.flip();
short dataset2 = buf.getShort();
int count2 = buf.getInt();
LOG.info("dataset: " + dataset2);
LOG.info("count: " + count2);
for (int k = 0; k < count2; ++k) {
int sceneid = buf.getInt();
long ts = buf.getLong();
byte cloudcover = buf.get();
byte proclevel = buf.get();
byte numBounds = buf.get();
double[] bounds = new double[numBounds];
for (byte j = 0; j < numBounds; ++j) {
bounds[j] = buf.getDouble();
}
System.out.println(sceneid + "|" + new Timestamp(ts).toDateString() + "|" + cloudcover + "|" + proclevel + "|" + numBounds + "|" + Arrays.toString(bounds));
}
indexMediator.disconnect();
SpatialIndexMediator indexMediator = SpatialIndexMediator.connect("localhost", MediatorConstants.PORT);
System.out.println("gms-database version: "+ Version.getVersionInfo());
System.out.println("server version: " + indexMediator.getServerVersionInfo());
// // ByteBuffer buf = ByteBuffer.allocate(1000000);
// ByteBuffer buf = ByteBuffer.allocate(100000000);
//
// double low = 42.372196452589;
// double left = 6.1190697187496;
// double up = 55.613615264148;
// double right = 17.237233781249;
// double[] roi = new double[] { left, low, right, low, right, up, left, up, left, low };
//
// Envelope e = new Envelope();
// for (int i = 0; i < roi.length; i += 2) {
// e.expandToInclude(roi[i], roi[i + 1]);
// }
//
// Timestamp start = new Timestamp(1900, 1, 1);
// Timestamp end = Timestamp.now();
//
// // indexMediator.countScenesGroupedByDatasets(e, start, end, buf);
// //
// // buf.flip();
// // short num = buf.getShort();
// // for (int i = 0; i < num; ++i) {
// // short dataset = buf.getShort();
// // int count = buf.getInt();
// // indexMediator.getScenesForDataset(e, start, end, dataset, buf2);
// // buf2.flip();
// // short dataset2 = buf2.getShort();
// // int count2 = buf2.getInt();
// // LOG.info("datasets: " + dataset + " vs. " + dataset2);
// // LOG.info("counts: " + count + " vs. " + count2);
// //
// // for (int k = 0; k < count2; ++k) {
// // int sceneid = buf2.getInt();
// // long ts = buf2.getLong();
// // byte numBounds = buf2.get();
// // double[] bounds = new double[numBounds];
// // for (byte j = 0; j < numBounds; ++j) {
// // bounds[j] = buf2.getDouble();
// // }
// //
// // System.out.println(sceneid + "|" + new Timestamp(ts).toDateString() + "|" + numBounds + "|" + Arrays.toString(bounds));
// // }
// // buf2.clear();
// // }
//
// indexMediator.getFullSceneDataForDataset(e, start, end, 0, (byte) 0, (byte) 100, (short) 108, (byte) 0, (byte) 100, buf);
// buf.flip();
// short dataset2 = buf.getShort();
// int count2 = buf.getInt();
// LOG.info("dataset: " + dataset2);
// LOG.info("count: " + count2);
//
// for (int k = 0; k < count2; ++k) {
// int sceneid = buf.getInt();
// long ts = buf.getLong();
// byte cloudcover = buf.get();
// byte proclevel = buf.get();
// byte numBounds = buf.get();
// double[] bounds = new double[numBounds];
// for (byte j = 0; j < numBounds; ++j) {
// bounds[j] = buf.getDouble();
// }
//
// System.out.println(
// sceneid + "|" + new Timestamp(ts).toDateString() + "|" + cloudcover + "|" + proclevel + "|" + numBounds + "|" + Arrays.toString(bounds));
// }
//
// indexMediator.disconnect();
}
}
package de.potsdam.gfz.gms.database;
import java.util.Date;
public final class Version {
public static final String build_number="@buildnumber@";
public static final String build_time="@buildtime@";
public static String getVersionInfo() {
return "GIT-Build: " + build_number.substring(0, 8) + " on " + new Date(getBuildTimestamp()).toString();
}
public static long getBuildTimestamp() {
try {
return Long.parseLong(Version.build_time);
} catch (Throwable t) {
}
return 0;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment