Skip to content

Commit c0b6365

Browse files
committed
Merge pull request #4 from ngageoint/develop
Central Repository version 1.0.0, GeoPackage Cache
2 parents c229503 + cca3891 commit c0b6365

File tree

3 files changed

+179
-10
lines changed

3 files changed

+179
-10
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Software source code previously released under an open source license and then m
1313

1414
GeoPackage Core provides core functionality for GeoPackage implementations of the Open Geospatial Consortium [GeoPackage](http://www.geopackage.org/) [spec](http://www.geopackage.org/spec/).
1515

16-
It is the core library of both the [GeoPackage Android](https://github.com/ngageoint/geopackage-android) SDK and [GeoPackage Java](https://github.com/ngageoint/geopackage-java) library.
16+
It is the core library of the [GeoPackage Android](https://github.com/ngageoint/geopackage-android) SDK and [GeoPackage Java](https://github.com/ngageoint/geopackage-java) library, both which can be found under [OGC GeoPackage Implementations](http://www.geopackage.org/#implementations) by the National Geospatial-Intelligence Agency.
1717

1818
### Usage ###
1919

@@ -29,10 +29,17 @@ The [GeoPackage MapCache](https://github.com/ngageoint/geopackage-mapcache-andro
2929

3030
The [GeoPackage Java](https://github.com/ngageoint/geopackage-java) library is a Java GeoPackage implementation.
3131

32-
### Build ###
32+
### Installation ###
33+
34+
Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga.geopackage|geopackage-core|1.0.0|jar)
3335

34-
The following repository must be built first (Central Repository Artifacts Coming Soon):
35-
* [GeoPackage WKB Java] (https://github.com/ngageoint/geopackage-wkb-java)
36+
<dependency>
37+
<groupId>mil.nga.geopackage</groupId>
38+
<artifactId>geopackage-core</artifactId>
39+
<version>1.0.0</version>
40+
</dependency>
41+
42+
### Build ###
3643

3744
Build this repository using Eclipse and/or Maven:
3845

pom.xml

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,85 @@
4848
<version>4.48</version>
4949
</dependency>
5050
<dependency>
51-
<groupId>mil.nga.wkb</groupId>
51+
<groupId>mil.nga</groupId>
5252
<artifactId>wkb</artifactId>
5353
<version>1.0.0</version>
5454
</dependency>
5555
<dependency>
56-
<groupId>junit</groupId>
57-
<artifactId>junit</artifactId>
58-
<version>4.11</version>
59-
<scope>test</scope>
60-
</dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit</artifactId>
58+
<version>4.11</version>
59+
<scope>test</scope>
60+
</dependency>
6161
</dependencies>
62+
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-source-plugin</artifactId>
68+
<version>2.2.1</version>
69+
<executions>
70+
<execution>
71+
<id>attach-sources</id>
72+
<goals>
73+
<goal>jar-no-fork</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-javadoc-plugin</artifactId>
81+
<version>2.9.1</version>
82+
<executions>
83+
<execution>
84+
<id>attach-javadocs</id>
85+
<goals>
86+
<goal>jar</goal>
87+
</goals>
88+
<configuration>
89+
<additionalparam>-Xdoclint:none</additionalparam>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-gpg-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<id>sign-artifacts</id>
100+
<phase>deploy</phase>
101+
<goals>
102+
<goal>sign</goal>
103+
</goals>
104+
</execution>
105+
</executions>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.sonatype.plugins</groupId>
109+
<artifactId>nexus-staging-maven-plugin</artifactId>
110+
<version>1.6.3</version>
111+
<extensions>true</extensions>
112+
<configuration>
113+
<serverId>ossrh</serverId>
114+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
115+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
116+
</configuration>
117+
</plugin>
118+
</plugins>
119+
</build>
120+
121+
<distributionManagement>
122+
<snapshotRepository>
123+
<id>ossrh</id>
124+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
125+
</snapshotRepository>
126+
<repository>
127+
<id>ossrh</id>
128+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
129+
</repository>
130+
</distributionManagement>
131+
62132
</project>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package mil.nga.geopackage;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
/**
7+
* Abstract GeoPackage Core Cache for maintaining and reusing open GeoPackage
8+
* connections
9+
*
10+
* @author osbornb
11+
*
12+
* @param <T>
13+
* templated GeoPackage object
14+
*/
15+
public abstract class GeoPackageCoreCache<T extends GeoPackageCore> {
16+
17+
/**
18+
* Cache of GeoPackage names and GeoPackages
19+
*/
20+
private Map<String, T> cache = new HashMap<String, T>();
21+
22+
/**
23+
* Constructor
24+
*/
25+
public GeoPackageCoreCache() {
26+
27+
}
28+
29+
/**
30+
* Get the GeoPackage with name
31+
*
32+
* @param name
33+
* @return cached GeoPackage
34+
*/
35+
public T get(String name) {
36+
return cache.get(name);
37+
}
38+
39+
/**
40+
* Checks if the GeoPackage name exists in the cache
41+
*
42+
* @param name
43+
* @return true if exists
44+
*/
45+
public boolean exists(String name) {
46+
return cache.containsKey(name);
47+
}
48+
49+
/**
50+
* Close all GeoPackages in the cache
51+
*/
52+
public void closeAll() {
53+
for (T geoPackage : cache.values()) {
54+
geoPackage.close();
55+
}
56+
cache.clear();
57+
}
58+
59+
/**
60+
* Add a GeoPackage to the cache
61+
*
62+
* @param geoPackage
63+
*/
64+
public void add(T geoPackage) {
65+
cache.put(geoPackage.getName(), geoPackage);
66+
}
67+
68+
/**
69+
* Remove the GeoPackage with the name
70+
*
71+
* @param name
72+
* @return removed GeoPackage
73+
*/
74+
public T remove(String name) {
75+
return cache.remove(name);
76+
}
77+
78+
/**
79+
* Remove and close the GeoPackage with name
80+
*
81+
* @param name
82+
* @return true if found, removed, and closed
83+
*/
84+
public boolean removeAndClose(String name) {
85+
T geoPackage = remove(name);
86+
if (geoPackage != null) {
87+
geoPackage.close();
88+
}
89+
return geoPackage != null;
90+
}
91+
92+
}

0 commit comments

Comments
 (0)