Skip to content

Commit

Permalink
[ADQL] Support J2000 as STC-S' frame (in addition of ICRS, FK4, FK5, …
Browse files Browse the repository at this point in the history
…...).
  • Loading branch information
gmantele committed Apr 3, 2017
1 parent 7a70c60 commit bae21b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/adql/db/STCS.java
Expand Up @@ -16,7 +16,7 @@
* 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;
Expand Down Expand Up @@ -78,7 +78,7 @@
* </i></p>
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 1.3 (12/2014)
* @version 1.4 (04/2017)
* @since 1.3
*/
public final class STCS {
Expand Down Expand Up @@ -143,11 +143,11 @@ private static String buildAllowedRegExp(final String rootRegExp){
* </i></p>
*
* @author Gr&eacute;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;
Expand Down Expand Up @@ -1329,7 +1329,7 @@ private void init(final String newStcs){
* @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:
Expand All @@ -1346,7 +1346,7 @@ private void end(final String expectedSyntax) throws ParseException{
}

/**
* 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)))
Expand Down
9 changes: 9 additions & 0 deletions test/adql/db/TestFunctionDef.java
Expand Up @@ -257,6 +257,15 @@ public void testParse(){
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
Expand Down
8 changes: 4 additions & 4 deletions test/adql/db/TestSTCS.java
Expand Up @@ -366,7 +366,7 @@ public void parseCoordSys(){
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:
Expand All @@ -375,7 +375,7 @@ public void parseCoordSys(){
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:
Expand Down Expand Up @@ -414,7 +414,7 @@ public void parseCoordSys(){
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());
}
}

Expand Down Expand Up @@ -518,7 +518,7 @@ public void parseRegion(){
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:
Expand Down

0 comments on commit bae21b0

Please sign in to comment.