/** * Constructs an authority factory using the specified connection. * * @param userHints The underlying factories used for objects creation. * @param dataSource The data source connecting to the underlying EPSG database */ public DirectEpsgFactory(final Hints userHints, final DataSource dataSource) { super(userHints, MAXIMUM_PRIORITY - 20); // The following hints have no effect on this class behaviour, // but tell to the user what this factory do about axis order. hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_DIRECTIONS, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_UNITS, Boolean.FALSE); this.dataSource = dataSource; this.lonLatFactory = new OrderedAxisAuthorityFactory(buffered, userHints, null); ensureNonNull("dataSource", dataSource); }
throws FactoryRegistryException, IllegalArgumentException { super(authority, userHints); forceStandardUnits = booleanValue(userHints, Hints.FORCE_STANDARD_AXIS_UNITS); forceStandardDirections = booleanValue(userHints, Hints.FORCE_STANDARD_AXIS_DIRECTIONS); directionRanks = computeDirectionRanks(axisOrder); completeHints();
/** * Completes the set of hints according the value currently set in this object. This method is * invoked by constructors only. */ private void completeHints() { hints.put(Hints.FORCE_STANDARD_AXIS_UNITS, Boolean.valueOf(forceStandardUnits)); hints.put(Hints.FORCE_STANDARD_AXIS_DIRECTIONS, Boolean.valueOf(forceStandardDirections)); // The following hint has no effect on this class behaviour, // but tells to the user what this factory do about axis order. if (compare(DefaultCoordinateSystemAxis.EASTING, DefaultCoordinateSystemAxis.NORTHING) < 0) { hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); } }
/** * Compares two axis for order. This method is invoked automatically by the {@link * #replace(CoordinateSystem) replace} method for ordering the axis in a coordinate system. The * default implementation orders the axis according their {@linkplain * CoordinateSystemAxis#getDirection direction}, using the direction table given at {@linkplain * #OrderedAxisAuthorityFactory(AbstractAuthorityFactory, Hints, AxisDirection[]) construction * time} (see also the class description). Subclasses may override this method if they want to * define a more sophesticated axis ordering. * * @param axis1 The first axis to compare. * @param axis2 The second axis to compare. * @return A negative integer if {@code axis1} should appears before {@code axis2}, or a * positive number if {@code axis2} should appears before {@code axis1}, or 0 if the two * axis are unordered one relative to the other. * @todo The argument type will be changed to {@link CoordinateSystemAxis} when we will be * allowed to compile for J2SE 1.5. * @since 2.3 */ public int compare(final Object axis1, final Object axis2) { return rank((CoordinateSystemAxis) axis1) - rank((CoordinateSystemAxis) axis2); }
/** Tests the amount of codes available. */ public void testCodes() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final Set codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); assertNotNull(codes); assertTrue(codes.size() >= 3000); }
/** * Creates a factory which will reorder the axis of all objects created by the supplied factory. * This constructor accepts the following optional hints: * * <p> * * <ul> * <li>{@link Hints#FORCE_STANDARD_AXIS_UNITS} * <li>{@link Hints#FORCE_STANDARD_AXIS_DIRECTIONS} * </ul> * * @param factory The factory that produces objects using arbitrary axis order. * @param userHints An optional set of hints, or {@code null} if none. * @param axisOrder An array of axis directions that determine the axis order wanted, or {@code * null} for the default axis order. * @throws IllegalArgumentException If at least two axis directions are colinear. * @since 2.3 */ public OrderedAxisAuthorityFactory( final AbstractAuthorityFactory factory, final Hints userHints, final AxisDirection[] axisOrder) throws IllegalArgumentException { super(factory); forceStandardUnits = booleanValue(userHints, Hints.FORCE_STANDARD_AXIS_UNITS); forceStandardDirections = booleanValue(userHints, Hints.FORCE_STANDARD_AXIS_DIRECTIONS); directionRanks = computeDirectionRanks(axisOrder); completeHints(); }
/** * Tests the number of CRS that can be created. This test will be executed only if this test * suite is run with the {@code -verbose} option provided on the command line. */ public void testSuccess() throws FactoryException { if (!verbose) { return; } final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); Set codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); int total = codes.size(); int count = 0; for (Iterator i = codes.iterator(); i.hasNext(); ) { CoordinateReferenceSystem crs; String code = (String) i.next(); try { crs = factory.createCoordinateReferenceSystem(code); assertNotNull(crs); count++; } catch (FactoryException e) { // System.err.println("WARNING (CRS: " + code + " ):" + e.getMessage()); } } // System.out.println("Success: " + count + "/" + total + " (" + (count * 100) / total + // "%)"); }
/** UDIG requires this to work. */ public void test4326() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:4326")); }
/** A random CRS for fun. */ public void test26910() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:26910"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:26910")); }
/** UDIG requires this to work. */ public void test4269() throws FactoryException { final CRSAuthorityFactory factory = new OrderedAxisAuthorityFactory("EPSG", null, null); final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4269"); assertNotNull(crs); assertSame(crs, factory.createObject("EPSG:4269")); }
throw new FactoryException(exception); return new OrderedAxisAuthorityFactory(factory, new Hints(hints), null);
throw new FactoryException(exception); return new OrderedAxisAuthorityFactory(factory, new Hints(hints), null);
/** Tests the vendor name. */ public void testVendor() { CRSAuthorityFactory factory; Citation vendor; factory = new OrderedAxisAuthorityFactory("EPSG", null, null); vendor = factory.getVendor(); assertNotNull(vendor); assertEquals("Geotools", vendor.getTitle().toString(Locale.US)); assertFalse(Citations.identifierMatches(vendor, "EPSG")); }
/** Makes sure that the authority factory has the proper name. */ public void testAuthority() { CRSAuthorityFactory factory; Citation authority; // Tests the official factory. factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null); authority = factory.getAuthority(); assertNotNull(authority); assertEquals("European Petroleum Survey Group", authority.getTitle().toString(Locale.US)); assertTrue(Citations.identifierMatches(authority, "EPSG")); // Tests the modified factory. factory = new OrderedAxisAuthorityFactory("EPSG", null, null); authority = factory.getAuthority(); assertNotNull(authority); assertTrue(Citations.identifierMatches(authority, "EPSG")); }