Skip to content
Snippets Groups Projects
Commit bae21b07 authored by gmantele's avatar gmantele
Browse files

[ADQL] Support J2000 as STC-S' frame (in addition of ICRS, FK4, FK5, ...).

parent 7a70c603
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package adql.db; ...@@ -16,7 +16,7 @@ package adql.db;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * 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; import java.util.ArrayList;
...@@ -78,7 +78,7 @@ import adql.query.operand.function.geometry.RegionFunction; ...@@ -78,7 +78,7 @@ import adql.query.operand.function.geometry.RegionFunction;
* </i></p> * </i></p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI)
* @version 1.3 (12/2014) * @version 1.4 (04/2017)
* @since 1.3 * @since 1.3
*/ */
public final class STCS { public final class STCS {
...@@ -143,11 +143,11 @@ public final class STCS { ...@@ -143,11 +143,11 @@ public final class STCS {
* </i></p> * </i></p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI)
* @version 1.3 (10/2014) * @version 1.4 (04/2017)
* @since 1.3 * @since 1.3
*/ */
public static enum Frame{ public static enum Frame{
ECLIPTIC, FK4, FK5, GALACTIC, ICRS, UNKNOWNFRAME; ECLIPTIC, FK4, FK5, J2000, GALACTIC, ICRS, UNKNOWNFRAME;
/** Default value for a frame: {@link #UNKNOWNFRAME}. */ /** Default value for a frame: {@link #UNKNOWNFRAME}. */
public static final Frame DEFAULT = UNKNOWNFRAME; public static final Frame DEFAULT = UNKNOWNFRAME;
...@@ -1329,7 +1329,7 @@ public final class STCS { ...@@ -1329,7 +1329,7 @@ public final class STCS {
* @param expectedSyntax Description of the good syntax expected. This description is used only to write the * @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. * {@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{ private void end(final String expectedSyntax) throws ParseException{
// Skip all spaces: // Skip all spaces:
...@@ -1346,7 +1346,7 @@ public final class STCS { ...@@ -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(){ private void skipSpaces(){
while(pos < stcs.length() && Character.isWhitespace(stcs.charAt(pos))) while(pos < stcs.length() && Character.isWhitespace(stcs.charAt(pos)))
......
...@@ -257,6 +257,15 @@ public class TestFunctionDef { ...@@ -257,6 +257,15 @@ public class TestFunctionDef {
ex.printStackTrace(System.err); ex.printStackTrace(System.err);
fail("Unknown types MUST be allowed!"); 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 @Test
......
...@@ -366,7 +366,7 @@ public class TestSTCS { ...@@ -366,7 +366,7 @@ public class TestSTCS {
fail(); fail();
}catch(Exception e){ }catch(Exception e){
assertTrue(e instanceof ParseException); 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: // With wrong reference position:
...@@ -375,7 +375,7 @@ public class TestSTCS { ...@@ -375,7 +375,7 @@ public class TestSTCS {
fail(); fail();
}catch(Exception e){ }catch(Exception e){
assertTrue(e instanceof ParseException); 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: // With a cartesian flavor:
...@@ -414,7 +414,7 @@ public class TestSTCS { ...@@ -414,7 +414,7 @@ public class TestSTCS {
fail(); fail();
}catch(Exception e){ }catch(Exception e){
assertTrue(e instanceof ParseException); 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 { ...@@ -518,7 +518,7 @@ public class TestSTCS {
fail(); fail();
}catch(Exception ex){ }catch(Exception ex){
assertTrue(ex instanceof ParseException); 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: // TEST WITH EITHER A WRONG NUMERIC (L in lower case instead of 1) OR A MISSING OPENING PARENTHESIS:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment