Author: jsorel Date: Fri Apr 8 12:43:53 2016 New Revision: 1738241 URL: http://svn.apache.org/viewvc?rev=1738241&view=rev Log: Add GPX reader and test samples Added: sis/branches/JDK8/storage/sis-xmlstore/ sis/branches/JDK8/storage/sis-xmlstore/pom.xml sis/branches/JDK8/storage/sis-xmlstore/src/ sis/branches/JDK8/storage/sis-xmlstore/src/main/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/CopyRight.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXVersion.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/MetaData.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/AbstractConfigurable.java sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamReader.java sis/branches/JDK8/storage/sis-xmlstore/src/main/resources/ sis/branches/JDK8/storage/sis-xmlstore/src/test/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/GPXReaderTest.java sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_metadata100.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_metadata110.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_route100.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_route110.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_track100.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_track110.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_waypoint100.xml sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/gpx/sample_waypoint110.xml Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java sis/branches/JDK8/ide-project/NetBeans/build.xml sis/branches/JDK8/ide-project/NetBeans/nbproject/build-impl.xml sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties sis/branches/JDK8/ide-project/NetBeans/nbproject/project.properties sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml sis/branches/JDK8/storage/pom.xml Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java [UTF-8] Fri Apr 8 12:43:53 2016 @@ -118,7 +118,7 @@ public final class Features extends Stat * otherwise the function return doing nothing. * * @param feature tested feature. - * @throws InvalidPropertyValueException + * @throws InvalidPropertyValueException if feature do not pass validation */ public static void validate(Feature feature) throws InvalidPropertyValueException { Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java (original) +++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java Fri Apr 8 12:43:53 2016 @@ -120,7 +120,7 @@ public class AttributeTypeBuilder { * * See {@link #DESCRIPTION_KEY} * - * @param description + * @param description attribute description */ public void setDescription(CharSequence description){ parameters.put(DESCRIPTION_KEY, description); @@ -131,7 +131,7 @@ public class AttributeTypeBuilder { * * See {@link #DESIGNATION_KEY} * - * @param designation + * @param designation attribute designation */ public void setDesignation(CharSequence designation){ parameters.put(DESIGNATION_KEY, designation); @@ -142,7 +142,7 @@ public class AttributeTypeBuilder { * * See {@link #DEFINITION_KEY} * - * @param definition + * @param definition attribute definition */ public void setDefinition(CharSequence definition){ parameters.put(DEFINITION_KEY, definition); @@ -160,7 +160,7 @@ public class AttributeTypeBuilder { /** * Set default attribute value. * - * @param defaultValue + * @param defaultValue attribute default value, can be null */ public void setDefaultValue(Object defaultValue) { this.defaultValue = defaultValue; @@ -169,7 +169,7 @@ public class AttributeTypeBuilder { /** * Set minimum occurrences of the attribute values. * - * @param minimumOccurs + * @param minimumOccurs must be positive */ public void setMinimumOccurs(int minimumOccurs) { this.minimumOccurs = minimumOccurs; @@ -178,7 +178,7 @@ public class AttributeTypeBuilder { /** * Set maximum occurrences of the attribute values. * - * @param maximumOccurs + * @param maximumOccurs must be positive and superior to minimum occurences */ public void setMaximumOccurs(int maximumOccurs) { this.maximumOccurs = maximumOccurs; @@ -188,7 +188,7 @@ public class AttributeTypeBuilder { * Set maximum attribute length. * This characteristic only have a meaning with CharSequence type attributes. * - * @param length + * @param length character sequence length * @return created characteristic */ public AttributeType setLengthCharacteristic(int length){ @@ -199,7 +199,7 @@ public class AttributeTypeBuilder { * Set attribute {@code CoordinateReferenceSystem}. * This characteristic only have a meaning with georeferenced type attributes. * - * @param crs + * @param crs geometry coordinate reference system * @return created characteristic */ public AttributeType setCRSCharacteristic(CoordinateReferenceSystem crs){ @@ -210,7 +210,7 @@ public class AttributeTypeBuilder { * Set attribute restricted values. * This characteristic defines a list of possible values for the attribute. * - * @param values + * @param values enumeration of values * @return created characteristic */ public AttributeType setPossibleValues(Collection values){ @@ -252,7 +252,7 @@ public class AttributeTypeBuilder { /** * Add a user defined characteristic. * - * @param characteristic + * @param characteristic not null * @return added characteristic */ public AttributeType addCharacteristic(AttributeType characteristic){ Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java (original) +++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java Fri Apr 8 12:43:53 2016 @@ -151,7 +151,7 @@ public class FeatureTypeBuilder { * * See {@link #DESCRIPTION_KEY} * - * @param description + * @param description feature type description */ public void setDescription(CharSequence description){ parameters.put(DESCRIPTION_KEY, description); @@ -162,7 +162,7 @@ public class FeatureTypeBuilder { * * See {@link #DESIGNATION_KEY} * - * @param designation + * @param designation feature type designation */ public void setDesignation(CharSequence designation){ parameters.put(DESIGNATION_KEY, designation); @@ -173,7 +173,7 @@ public class FeatureTypeBuilder { * * See {@link #DEFINITION_KEY} * - * @param definition + * @param definition feature type definition */ public void setDefinition(CharSequence definition){ parameters.put(DEFINITION_KEY, definition); @@ -182,7 +182,7 @@ public class FeatureTypeBuilder { /** * Set feature type abstract. * - * @param abstrac + * @param abstrac long description of the feature type */ public void setAbstract(boolean abstrac) { this.isAbstract = abstrac; @@ -740,7 +740,7 @@ public class FeatureTypeBuilder { * if the given string do not match any, then a Name with no namespace will be * created and the localpart will be the given string. * - * @param candidate + * @param candidate String to convert to a geoneric name * @return Name */ private static GenericName valueOf(final String candidate){ @@ -787,8 +787,8 @@ public class FeatureTypeBuilder { * String can be written with only the local part or in extendedform or JCR * extended form. * - * @param name - * @param candidate + * @param name expected generic name + * @param candidate name to test * @return true if the string match the name */ private static boolean match(final GenericName name, final String candidate){ Modified: sis/branches/JDK8/ide-project/NetBeans/build.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/build.xml?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/ide-project/NetBeans/build.xml (original) +++ sis/branches/JDK8/ide-project/NetBeans/build.xml Fri Apr 8 12:43:53 2016 @@ -186,6 +186,10 @@ + + + + Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/build-impl.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/build-impl.xml?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/ide-project/NetBeans/nbproject/build-impl.xml (original) +++ sis/branches/JDK8/ide-project/NetBeans/nbproject/build-impl.xml Fri Apr 8 12:43:53 2016 @@ -125,6 +125,7 @@ is divided into following sections: + @@ -140,6 +141,7 @@ is divided into following sections: + @@ -252,6 +254,7 @@ is divided into following sections: Must set src.console.dir Must set src.netcdf.dir Must set src.shapefile.dir + Must set src.xmlstore.dir Must set src.storage.dir Must set src.feature.dir Must set src.referencing.dir @@ -261,6 +264,7 @@ is divided into following sections: Must set test.console.dir Must set test.netcdf.dir Must set test.shapefile.dir + Must set test.xmlstore.dir Must set test.storage.dir Must set test.feature.dir Must set test.referencing.dir @@ -287,7 +291,7 @@ is divided into following sections: - + @@ -328,7 +332,7 @@ is divided into following sections: - + @@ -361,7 +365,7 @@ is divided into following sections: - + @@ -457,6 +461,9 @@ is divided into following sections: + + + @@ -513,6 +520,9 @@ is divided into following sections: + + + @@ -649,6 +659,9 @@ is divided into following sections: + + + @@ -1039,7 +1052,7 @@ is divided into following sections: - + @@ -1049,6 +1062,7 @@ is divided into following sections: + @@ -1075,7 +1089,7 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + @@ -1356,6 +1370,9 @@ is divided into following sections: + + + @@ -1396,6 +1413,9 @@ is divided into following sections: + + + @@ -1436,14 +1456,15 @@ is divided into following sections: - + - + + @@ -1464,11 +1485,12 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + + Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Fri Apr 8 12:43:53 2016 @@ -3,6 +3,6 @@ build.xml.data.CRC32=58e6b21c build.xml.script.CRC32=462eaba0 build.xml.stylesheet.CRC32=28e38971@1.53.1.46 -nbproject/build-impl.xml.data.CRC32=21ae62d4 -nbproject/build-impl.xml.script.CRC32=e337b80c +nbproject/build-impl.xml.data.CRC32=8c88ad6d +nbproject/build-impl.xml.script.CRC32=cc691eca nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/project.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/project.properties?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Fri Apr 8 12:43:53 2016 @@ -52,6 +52,8 @@ src.netcdf.dir = ${project.root}/s test.netcdf.dir = ${project.root}/storage/sis-netcdf/src/test/java src.shapefile.dir = ${project.root}/storage/sis-shapefile/src/main/java test.shapefile.dir = ${project.root}/storage/sis-shapefile/src/test/java +src.xmlstore.dir = ${project.root}/storage/sis-xmlstore/src/main/java +test.xmlstore.dir = ${project.root}/storage/sis-xmlstore/src/test/java src.storage.dir = ${project.root}/storage/sis-storage/src/main/java test.storage.dir = ${project.root}/storage/sis-storage/src/test/java src.feature.dir = ${project.root}/core/sis-feature/src/main/java Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml (original) +++ sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml Fri Apr 8 12:43:53 2016 @@ -28,6 +28,7 @@ + @@ -39,6 +40,7 @@ + Modified: sis/branches/JDK8/storage/pom.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/pom.xml?rev=1738241&r1=1738240&r2=1738241&view=diff ============================================================================== --- sis/branches/JDK8/storage/pom.xml (original) +++ sis/branches/JDK8/storage/pom.xml Fri Apr 8 12:43:53 2016 @@ -138,6 +138,7 @@ sis-storage sis-shapefile sis-netcdf + sis-xmlstore Added: sis/branches/JDK8/storage/sis-xmlstore/pom.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/pom.xml?rev=1738241&view=auto ============================================================================== --- sis/branches/JDK8/storage/sis-xmlstore/pom.xml (added) +++ sis/branches/JDK8/storage/sis-xmlstore/pom.xml Fri Apr 8 12:43:53 2016 @@ -0,0 +1,114 @@ + + + + + + 4.0.0 + + + org.apache.sis + storage + 0.7-jdk8-SNAPSHOT + + + + + org.apache.sis.storage + sis-xmlstore + bundle + Apache SIS XML storage + + +Read and write files in the GPX format. + + + + + + + Johann Sorel + jsorel + johann.sorel@geomatys.com + + developer + + + + + + + + + + + + org.apache.sis.core + sis-build-helper + ${sis.plugin.version} + + + + compile-resources + + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.sis.storage.xmlstore + + + + + + + + + + + org.apache.sis.core + sis-feature + ${project.version} + + + org.apache.sis.storage + sis-storage + ${project.version} + + + + Added: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/CopyRight.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/CopyRight.java?rev=1738241&view=auto ============================================================================== --- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/CopyRight.java (added) +++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/CopyRight.java Fri Apr 8 12:43:53 2016 @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.internal.gpx; + +import java.net.URI; + +/** + * Copyright object as defined in GPX. + * + * @author Johann Sorel (Geomatys) + * @since 0.7 + * @version 0.7 + * @module + */ +public class CopyRight { + + private String author; + private Integer year; + private URI license; + + /** + * Returns the author value. + * + * @return author, may be null + */ + public String getAuthor() { + return author; + } + + /** + * Set author value. + * + * @param author, can be null + */ + public void setAuthor(String author) { + this.author = author; + } + + /** + * Returns the copyright year. + * + * @return copyright year, may be null + */ + public Integer getYear() { + return year; + } + + /** + * Set copyright year value. + * + * @param year, can be null + */ + public void setYear(Integer year) { + this.year = year; + } + + /** + * Returns the license URI. + * + * @return license, may be null + */ + public URI getLicense() { + return license; + } + + /** + * Set license URI. + * + * @param license, can be null + */ + public void setLicense(URI license) { + this.license = license; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("CopyRight("); + sb.append(author).append(',').append(year).append(',').append(license); + sb.append(')'); + return sb.toString(); + } + +} Added: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java?rev=1738241&view=auto ============================================================================== --- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java (added) +++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java Fri Apr 8 12:43:53 2016 @@ -0,0 +1,402 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.internal.gpx; + +import com.esri.core.geometry.Point; +import java.net.URI; +import java.time.temporal.Temporal; +import java.util.Collections; +import org.apache.sis.feature.AbstractIdentifiedType; +import org.apache.sis.internal.feature.AttributeTypeBuilder; +import org.apache.sis.feature.DefaultAttributeType; +import org.apache.sis.internal.feature.FeatureTypeBuilder; +import org.apache.sis.internal.system.DefaultFactories; +import org.apache.sis.referencing.CommonCRS; +import org.apache.sis.util.Static; +import org.opengis.feature.AttributeType; +import org.opengis.feature.FeatureAssociationRole; +import org.opengis.feature.FeatureType; +import org.opengis.feature.Operation; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.util.GenericName; +import org.opengis.util.NameFactory; + +/** + * GPX XML tags and feature types. + * + * @author Johann Sorel (Geomatys) + * @since 0.7 + * @version 0.7 + * @module + */ +public final class GPXConstants extends Static { + + /** + * Main GPX xml tag. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_GPX = "gpx"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_GPX_VERSION = "version"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_GPX_CREATOR = "creator"; + + /** + * Attributs used a bit everywhere. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_NAME = "name"; + /** used in version : 1.0 */ + public static final String TAG_URL = "url"; + /** used in version : 1.0 */ + public static final String TAG_URLNAME = "urlname"; + /** used in version : 1.1 */ + public static final String TAG_LINK = "link"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_DESC = "desc"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_CMT = "cmt"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_SRC = "src"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_TYPE = "type"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_NUMBER = "number"; + + /** + * Metadata tag. + */ + /** used in version : 1.1 */ + public static final String TAG_METADATA = "metadata"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_METADATA_TIME = "time"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_METADATA_KEYWORDS = "keywords"; + + /** + * Person tag. + */ + /** used in version : 1.0(as attribut) and 1.1(as tag) */ + public static final String TAG_AUTHOR = "author"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_AUTHOR_EMAIL = "email"; + + /** + * CopyRight tag. + */ + /** used in version : 1.1 */ + public static final String TAG_COPYRIGHT = "copyright"; + /** used in version : 1.1 */ + public static final String TAG_COPYRIGHT_YEAR = "year"; + /** used in version : 1.1 */ + public static final String TAG_COPYRIGHT_LICENSE = "license"; + /** used in version : 1.1 */ + public static final String ATT_COPYRIGHT_AUTHOR = "author"; + + /** + * Bounds tag. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_BOUNDS = "bounds"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_BOUNDS_MINLAT = "minlat"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_BOUNDS_MINLON = "minlon"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_BOUNDS_MAXLAT = "maxlat"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_BOUNDS_MAXLON = "maxlon"; + + /** + * Link tag. + */ + /** used in version : 1.1 */ + public static final String TAG_LINK_TEXT = "text"; + /** used in version : 1.1 */ + public static final String TAG_LINK_TYPE = "type"; + /** used in version : 1.1 */ + public static final String ATT_LINK_HREF = "href"; + + /** + * WPT tag. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT = "wpt"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_WPT_LAT = "lat"; + /** used in version : 1.0 and 1.1 */ + public static final String ATT_WPT_LON = "lon"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_ELE = "ele"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_TIME = "time"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_MAGVAR = "magvar"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_GEOIHEIGHT = "geoidheight"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_SYM = "sym"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_FIX = "fix"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_SAT = "sat"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_HDOP = "hdop"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_VDOP = "vdop"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_PDOP = "pdop"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_AGEOFGPSDATA = "ageofdgpsdata"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_WPT_DGPSID = "dgpsid"; + + /** + * RTE tag. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_RTE = "rte"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_RTE_RTEPT = "rtept"; + + /** + * TRK tag. + */ + /** used in version : 1.0 and 1.1 */ + public static final String TAG_TRK = "trk"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_TRK_SEG = "trkseg"; + /** used in version : 1.0 and 1.1 */ + public static final String TAG_TRK_SEG_PT = "trkpt"; + + /** + * Coordinate reference system used by gpx files. + */ + public static final CoordinateReferenceSystem GPX_CRS = CommonCRS.WGS84.normalizedGeographic(); + /** + * GPX scope name used for feature type names. + */ + public static final String GPX_NAMESPACE = "http://www.topografix.com"; + /** + * GPX 1.1 xml namespace + */ + public static final String GPX_NAMESPACE_V11 = "http://www.topografix.com/GPX/1/1"; + /** + * GPX 1.0 xml namespace + */ + public static final String GPX_NAMESPACE_V10 = "http://www.topografix.com/GPX/1/0"; + + /** + * Parent feature type of all gpx types. + */ + public static final FeatureType TYPE_GPX_ENTITY; + /** + * Waypoint GPX feature type. + */ + public static final FeatureType TYPE_WAYPOINT; + /** + * Track GPX feature type. + */ + public static final FeatureType TYPE_TRACK; + /** + * Route GPX feature type. + */ + public static final FeatureType TYPE_ROUTE; + /** + * Track segment GPX feature type. + */ + public static final FeatureType TYPE_TRACK_SEGMENT; + + + static { + final FeatureTypeBuilder ftb = new FeatureTypeBuilder(); + final AttributeTypeBuilder atb = new AttributeTypeBuilder(); + + //-------------------- GENERIC GPX ENTITY ------------------------------ + final AttributeType attIndex = createAttribute("index",Integer.class,1,1,null); + final String geomName = "geometry"; + + ftb.reset(); + ftb.setName(GPX_NAMESPACE, "GPXEntity"); + ftb.setAbstract(true); + ftb.addProperty(attIndex); + TYPE_GPX_ENTITY = ftb.build(); + + //------------------- WAY POINT TYPE ----------------------------------- + //lat="latitudeType [1] ?" + //lon="longitudeType [1] ?"> + // xsd:decimal [0..1] ? + // [0..1] ? + // degreesType [0..1] ? + // xsd:decimal [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // linkType [0..*] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // fixType [0..1] ? + // xsd:nonNegativeInteger [0..1] ? + // xsd:decimal [0..1] ? + // xsd:decimal [0..1] ? + // xsd:decimal [0..1] ? + // xsd:decimal [0..1] ? + // dgpsStationType [0..1] ? + // extensionsType [0..1] ? + atb.setName(createName(geomName)); + atb.setValueClass(Point.class); + atb.setCRSCharacteristic(GPX_CRS); + atb.setMinimumOccurs(1); + atb.setMaximumOccurs(1); + final AttributeType attPointGeometry = atb.build(); + final AttributeType attWptEle = createAttribute(TAG_WPT_ELE, Double.class,0,1,null); + final AttributeType attWptTime = createAttribute(TAG_WPT_TIME, Temporal.class,0,1,null); + final AttributeType attWptMagvar = createAttribute(TAG_WPT_MAGVAR, Double.class,0,1,null); + final AttributeType attWptGeoHeight = createAttribute(TAG_WPT_GEOIHEIGHT, Double.class,0,1,null); + final AttributeType attName = createAttribute(TAG_NAME, String.class,0,1,null); + final AttributeType attCmt = createAttribute(TAG_CMT, String.class,0,1,null); + final AttributeType attDesc = createAttribute(TAG_DESC, String.class,0,1,null); + final AttributeType attSrc = createAttribute(TAG_SRC, String.class,0,1,null); + final AttributeType attLink = createAttribute(TAG_LINK, URI.class,0,Integer.MAX_VALUE,null); + final AttributeType attWptSym = createAttribute(TAG_WPT_SYM, String.class,0,1,null); + final AttributeType attType = createAttribute(TAG_TYPE, String.class,0,1,null); + final AttributeType attWptFix = createAttribute(TAG_WPT_FIX, String.class,0,1,null); + final AttributeType attWptSat = createAttribute(TAG_WPT_SAT, Integer.class,0,1,null); + final AttributeType attWptHdop = createAttribute(TAG_WPT_HDOP, Double.class,0,1,null); + final AttributeType attWptVdop = createAttribute(TAG_WPT_VDOP, Double.class,0,1,null); + final AttributeType attWptPdop = createAttribute(TAG_WPT_PDOP, Double.class,0,1,null); + final AttributeType attWptAgeofGpsData = createAttribute(TAG_WPT_AGEOFGPSDATA, Double.class,0,1,null); + final AttributeType attWptDgpsid = createAttribute(TAG_WPT_DGPSID, Integer.class,0,1,null); + + ftb.reset(); + ftb.setName(GPX_NAMESPACE, "WayPoint"); + ftb.setSuperTypes(TYPE_GPX_ENTITY); + ftb.addProperty(attIndex); + ftb.addProperty(attPointGeometry); + ftb.addProperty(attWptEle); + ftb.addProperty(attWptTime); + ftb.addProperty(attWptMagvar); + ftb.addProperty(attWptGeoHeight); + ftb.addProperty(attName); + ftb.addProperty(attCmt); + ftb.addProperty(attDesc); + ftb.addProperty(attSrc); + ftb.addProperty(attLink); + ftb.addProperty(attWptSym); + ftb.addProperty(attType); + ftb.addProperty(attWptFix); + ftb.addProperty(attWptSat); + ftb.addProperty(attWptHdop); + ftb.addProperty(attWptVdop); + ftb.addProperty(attWptPdop); + ftb.addProperty(attWptAgeofGpsData); + ftb.addProperty(attWptDgpsid); + ftb.setDefaultGeometryOperation(attPointGeometry.getName()); + TYPE_WAYPOINT = ftb.build(); + + + //------------------- ROUTE TYPE --------------------------------------- + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // linkType [0..*] ? + // xsd:nonNegativeInteger [0..1] ? + // xsd:string [0..1] ? + // extensionsType [0..1] ? + // wptType [0..*] ? + final AttributeType attNumber = createAttribute(TAG_NUMBER, Integer.class,0,1,null); + + ftb.reset(); + ftb.setName(GPX_NAMESPACE, "Route"); + ftb.setSuperTypes(TYPE_GPX_ENTITY); + ftb.addProperty(attIndex); + ftb.addProperty(attName); + ftb.addProperty(attCmt); + ftb.addProperty(attDesc); + ftb.addProperty(attSrc); + ftb.addProperty(attLink); + ftb.addProperty(attNumber); + ftb.addProperty(attType); + final FeatureAssociationRole attWayPoints = ftb.addAssociation(createName(TAG_RTE_RTEPT),TYPE_WAYPOINT,0,Integer.MAX_VALUE); + final Operation attRouteGeometry = new GroupPointsAsPolylineOperation(createName(geomName),attWayPoints.getName(), attPointGeometry.getName()); + ftb.addProperty(attRouteGeometry); + ftb.setDefaultGeometryOperation(attRouteGeometry.getName()); + TYPE_ROUTE = ftb.build(); + + + //------------------- TRACK SEGMENT TYPE ------------------------------- + // wptType [0..*] ? + // extensionsType [0..1] ? + ftb.reset(); + ftb.setName(GPX_NAMESPACE, "TrackSegment"); + ftb.addProperty(attIndex); + final FeatureAssociationRole attTrackPoints = ftb.addAssociation(createName(TAG_TRK_SEG_PT),TYPE_WAYPOINT,0,Integer.MAX_VALUE); + final Operation attTrackSegGeometry = new GroupPointsAsPolylineOperation(createName(geomName),attTrackPoints.getName(), attPointGeometry.getName()); + ftb.addProperty(attTrackSegGeometry); + ftb.setDefaultGeometryOperation(attTrackSegGeometry.getName()); + TYPE_TRACK_SEGMENT = ftb.build(); + + //------------------- TRACK TYPE --------------------------------------- + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // xsd:string [0..1] ? + // linkType [0..*] ? + // xsd:nonNegativeInteger [0..1] ? + // xsd:string [0..1] ? + // extensionsType [0..1] ? + // trksegType [0..*] ? + ftb.reset(); + ftb.setName(GPX_NAMESPACE, "Track"); + ftb.setSuperTypes(TYPE_GPX_ENTITY); + ftb.addProperty(attIndex); + ftb.addProperty(attName); + ftb.addProperty(attCmt); + ftb.addProperty(attDesc); + ftb.addProperty(attSrc); + ftb.addProperty(attLink); + ftb.addProperty(attNumber); + ftb.addProperty(attType); + final FeatureAssociationRole attTrackSegments = ftb.addAssociation(createName(TAG_TRK_SEG),TYPE_TRACK_SEGMENT,0,Integer.MAX_VALUE); + final Operation attTrackGeometry = new GroupPolylinesOperation(createName(geomName),attTrackSegments.getName(), attTrackSegGeometry.getName()); + ftb.addProperty(attTrackGeometry); + ftb.setDefaultGeometryOperation(attTrackGeometry.getName()); + TYPE_TRACK = ftb.build(); + + } + + /** + * Shortcut method to create attribute type. + */ + private static AttributeType createAttribute(String name, Class valueClass, int min, int max, Object defaultValue) { + return new DefaultAttributeType(Collections.singletonMap(AbstractIdentifiedType.NAME_KEY, + createName(name)), valueClass, min, max, defaultValue); + } + + /** + * Shortcut method to create generic name in GPX scope. + */ + private static GenericName createName(String localPart) { + final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class); + return factory.createGenericName(null, GPX_NAMESPACE, localPart); + } + + private GPXConstants(){}; + +}