diff --git a/src/adql/db/STCS.java b/src/adql/db/STCS.java index b0befa1c724e886196a4a7f7d2b375981b3783df..ffeec759814652e0dd47cba3495f6feb2f97689e 100644 --- a/src/adql/db/STCS.java +++ b/src/adql/db/STCS.java @@ -16,7 +16,7 @@ package adql.db; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2014 - Astronomisches Rechen Institut (ARI) + * Copyright 2014-2017 - Astronomisches Rechen Institut (ARI) */ import java.util.ArrayList; @@ -78,7 +78,7 @@ import adql.query.operand.function.geometry.RegionFunction; * </i></p> * * @author Grégory Mantelet (ARI) - * @version 1.3 (12/2014) + * @version 1.4 (04/2017) * @since 1.3 */ public final class STCS { @@ -143,11 +143,11 @@ public final class STCS { * </i></p> * * @author Grégory Mantelet (ARI) - * @version 1.3 (10/2014) + * @version 1.4 (04/2017) * @since 1.3 */ public static enum Frame{ - ECLIPTIC, FK4, FK5, GALACTIC, ICRS, UNKNOWNFRAME; + ECLIPTIC, FK4, FK5, J2000, GALACTIC, ICRS, UNKNOWNFRAME; /** Default value for a frame: {@link #UNKNOWNFRAME}. */ public static final Frame DEFAULT = UNKNOWNFRAME; @@ -1329,7 +1329,7 @@ public final class STCS { * @param expectedSyntax Description of the good syntax expected. This description is used only to write the * {@link ParseException} in case other non-space characters are found among the remaining characters. * - * @throws ParseException If other non-space characters remains. + * @throws ParseException If other non-space characters remains. */ private void end(final String expectedSyntax) throws ParseException{ // Skip all spaces: @@ -1346,7 +1346,7 @@ public final class STCS { } /** - * Tool function which skip all next space characters until the next meaningful characters. + * Tool function which skip all next space characters until the next meaningful characters. */ private void skipSpaces(){ while(pos < stcs.length() && Character.isWhitespace(stcs.charAt(pos))) diff --git a/test/adql/db/TestFunctionDef.java b/test/adql/db/TestFunctionDef.java index ee87a7d7dab00b4fbb20af5aad8d3b67c5dcca45..9f63f78774f631bf1406d4f3065540b0fd818ce6 100644 --- a/test/adql/db/TestFunctionDef.java +++ b/test/adql/db/TestFunctionDef.java @@ -257,6 +257,15 @@ public class TestFunctionDef { ex.printStackTrace(System.err); fail("Unknown types MUST be allowed!"); } + try{ + FunctionDef fct = FunctionDef.parse("INTERSECTION(region1 region, region2 region) -> region"); + assertEquals(DBType.DBDatatype.REGION, fct.getParam(0).type.type); + assertEquals(DBType.DBDatatype.REGION, fct.getParam(1).type.type); + assertEquals(DBType.DBDatatype.REGION, fct.returnType.type); + }catch(Exception ex){ + ex.printStackTrace(System.err); + fail("Impossible to parse this REGION based FunctionDef! (see console for more details)"); + } } @Test diff --git a/test/adql/db/TestSTCS.java b/test/adql/db/TestSTCS.java index 8ff76460c076c73b611c4e8cf1e564b55aa6c91b..2f7698da8bbae233a8c81b2c5cda58683d83936a 100644 --- a/test/adql/db/TestSTCS.java +++ b/test/adql/db/TestSTCS.java @@ -366,7 +366,7 @@ public class TestSTCS { fail(); }catch(Exception e){ assertTrue(e instanceof ParseException); - assertEquals("Incorrect syntax: \"HOME\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); + assertEquals("Incorrect syntax: \"HOME\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|J2000|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); } // With wrong reference position: @@ -375,7 +375,7 @@ public class TestSTCS { fail(); }catch(Exception e){ assertTrue(e instanceof ParseException); - assertEquals("Incorrect syntax: \"HOME SPHERICAL2\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); + assertEquals("Incorrect syntax: \"HOME SPHERICAL2\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|J2000|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); } // With a cartesian flavor: @@ -414,7 +414,7 @@ public class TestSTCS { fail(); }catch(Exception e){ assertTrue(e instanceof ParseException); - assertEquals("Incorrect syntax: \"icrsGeocentercarteSIAN2\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); + assertEquals("Incorrect syntax: \"icrsGeocentercarteSIAN2\" was unexpected! Expected syntax: \"[(ECLIPTIC|FK4|FK5|J2000|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.", e.getMessage()); } } @@ -518,7 +518,7 @@ public class TestSTCS { fail(); }catch(Exception ex){ assertTrue(ex instanceof ParseException); - assertTrue(ex.getMessage().startsWith("Incorrect syntax: a coordinates pair (2 numerics separated by one or more spaces) was expected! Expected syntax: \"CIRCLE <coordSys> <coordPair> <radius>\", where coordPair=\"<numeric> <numeric>\", radius=\"<numeric>\" and coordSys=\"[(ECLIPTIC|FK4|FK5|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.")); + assertTrue(ex.getMessage().startsWith("Incorrect syntax: a coordinates pair (2 numerics separated by one or more spaces) was expected! Expected syntax: \"CIRCLE <coordSys> <coordPair> <radius>\", where coordPair=\"<numeric> <numeric>\", radius=\"<numeric>\" and coordSys=\"[(ECLIPTIC|FK4|FK5|J2000|GALACTIC|ICRS|UNKNOWNFRAME)] [(BARYCENTER|GEOCENTER|HELIOCENTER|LSR|TOPOCENTER|RELOCATABLE|UNKNOWNREFPOS)] [(CARTESIAN2|CARTESIAN3|SPHERICAL2)]\" ; an empty string is also allowed and will be interpreted as the coordinate system locally used.")); } // TEST WITH EITHER A WRONG NUMERIC (L in lower case instead of 1) OR A MISSING OPENING PARENTHESIS: