Strabon

changeset 980:2171270604e1

added OGCConstants. Currently, it contains only units of measure. Also, made endpoint publicize the URIs of the supported units.
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Apr 05 13:09:04 2013 +0300 (2013-04-05)
parents 04f844c4e2b9
children 45539016f159 f3fa13082d55
files constants/src/main/java/eu/earthobservatory/constants/OGCConstants.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/constants/src/main/java/eu/earthobservatory/constants/OGCConstants.java	Fri Apr 05 13:09:04 2013 +0300
     1.3 @@ -0,0 +1,58 @@
     1.4 +/**
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 + * 
     1.9 + * Copyright (C) 2012, Pyravlos Team
    1.10 + * 
    1.11 + * http://www.strabon.di.uoa.gr/
    1.12 + */
    1.13 +package eu.earthobservatory.constants;
    1.14 +
    1.15 +import java.lang.reflect.Field;
    1.16 +import java.util.ArrayList;
    1.17 +import java.util.List;
    1.18 +
    1.19 +/**
    1.20 + * This class contains several OGC constants that are mainly URIs.
    1.21 + * These can be found at the OGC Definition Service located at
    1.22 + * <a>http://www.opengis.net/def/</a>.
    1.23 + * 
    1.24 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    1.25 + */
    1.26 +public class OGCConstants {
    1.27 +
    1.28 +	/**
    1.29 +	 * Namespace for OGC Units of Measure 1.0
    1.30 +	 */
    1.31 +	public static final String UOM	= "http://www.opengis.net/def/uom/OGC/1.0/";
    1.32 +	
    1.33 +	public static final String OGCdegree		= UOM + "degree";
    1.34 +	public static final String OGCgridSpacing 	= UOM + "GridSpacing";
    1.35 +	public static final String OGCmetre			= UOM + "metre";
    1.36 +	public static final String OGCradian		= UOM + "radian";
    1.37 +	public static final String OGCunity			= UOM + "unity";
    1.38 +	
    1.39 +	public static final List<String> supportedUnitsOfMeasure = new ArrayList<String>();
    1.40 +	
    1.41 +	static {
    1.42 +		Class<OGCConstants> geoConstants = OGCConstants.class;	
    1.43 +		
    1.44 +		try {
    1.45 +			Field[] field = geoConstants.getDeclaredFields();
    1.46 +		
    1.47 +			for (int i = 0; i < field.length; i++) {
    1.48 +				if (field[i].getName().startsWith("OGC")) {
    1.49 +					supportedUnitsOfMeasure.add((String) field[i].get(null));
    1.50 +				}
    1.51 +			}
    1.52 +					
    1.53 +		} catch (SecurityException e) {
    1.54 +			// suppress exception; it should not reach here
    1.55 +		} catch (IllegalArgumentException e) {
    1.56 +			// suppress exception; it should not reach here 
    1.57 +		} catch (IllegalAccessException e) {
    1.58 +			// suppress exception; it should not reach here
    1.59 +		}
    1.60 +	}
    1.61 +}
     2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java	Fri Apr 05 11:59:56 2013 +0300
     2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java	Fri Apr 05 13:09:04 2013 +0300
     2.3 @@ -262,4 +262,12 @@
     2.4  	public List<String> getGeoSPARQLSpatialExtensionFunctions() {
     2.5  		return null;
     2.6  	}
     2.7 +
     2.8 +	/* (non-Javadoc)
     2.9 +	 * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getUnitsOfMeasure()
    2.10 +	 */
    2.11 +	@Override
    2.12 +	public List<String> getUnitsOfMeasure() {
    2.13 +		return null;
    2.14 +	}
    2.15  }
     3.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java	Fri Apr 05 11:59:56 2013 +0300
     3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java	Fri Apr 05 13:09:04 2013 +0300
     3.3 @@ -108,6 +108,15 @@
     3.4  	public List<String> getGeoSPARQLSpatialExtensionFunctions();
     3.5  	
     3.6  	/**
     3.7 +	 * Return a list of URIs corresponding to the units of measure
     3.8 +	 * that can be used in an extension function requiring such an
     3.9 +	 * argument.
    3.10 +	 * 
    3.11 +	 * @return
    3.12 +	 */
    3.13 +	public List<String> getUnitsOfMeasure();
    3.14 +	
    3.15 +	/**
    3.16  	 * Returns a {@link RequestCapabilities} instance containing
    3.17  	 * the details for how one can query the Query service of the
    3.18  	 * endpoint.
     4.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java	Fri Apr 05 11:59:56 2013 +0300
     4.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java	Fri Apr 05 13:09:04 2013 +0300
     4.3 @@ -156,6 +156,17 @@
     4.4  				out.println(extFunc);
     4.5  			}
     4.6  		}
     4.7 +		
     4.8 +		out.println();
     4.9 +		
    4.10 +		// print supported units of measure
    4.11 +		if (caps.getUnitsOfMeasure() != null) {
    4.12 +			out.println("Supported Units of Measure (OGC)");
    4.13 +			out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    4.14 +			for(String uom : caps.getUnitsOfMeasure()) {
    4.15 +				out.println(uom);
    4.16 +			}
    4.17 +		}
    4.18  	}
    4.19  	
    4.20  	private String getYesNo(boolean val) {
     5.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java	Fri Apr 05 11:59:56 2013 +0300
     5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java	Fri Apr 05 13:09:04 2013 +0300
     5.3 @@ -18,6 +18,7 @@
     5.4  import org.slf4j.LoggerFactory;
     5.5  
     5.6  import eu.earthobservatory.constants.GeoConstants;
     5.7 +import eu.earthobservatory.constants.OGCConstants;
     5.8  
     5.9  
    5.10  /**
    5.11 @@ -139,4 +140,9 @@
    5.12  	public List<String> getGeoSPARQLSpatialExtensionFunctions() {
    5.13  		return GeoConstants.GEOSPARQLExtFunc;
    5.14  	}
    5.15 +
    5.16 +	@Override
    5.17 +	public List<String> getUnitsOfMeasure() {
    5.18 +		return OGCConstants.supportedUnitsOfMeasure;
    5.19 +	}
    5.20  }