MIFParser implements FeatureCollectionParser { @Override public SimpleFeatureCollection parse(File file, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws ServiceException { URL url; try { url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new UserLayerException("Failed to parse MIF: " + e.getMessage(), UserLayerException.ErrorType.PARSER); } Map<String, Serializable> params = new HashMap<>(); params.put("url", url); DataStore store = null; try { store = DataStoreFinder.getDataStore(params); String typeName = store.getTypeNames()[0]; SimpleFeatureSource source = store.getFeatureSource(typeName); CoordinateReferenceSystem crs = source.getSchema() .getGeometryDescriptor() .getCoordinateReferenceSystem(); if (crs != null) { sourceCRS = crs; } return FeatureCollectionParsers.read(source, sourceCRS, targetCRS); } catch (ServiceException e) { throw e; } catch (Exception e) { throw new UserLayerException("Failed to parse MIF: " + e.getMessage(), UserLayerException.ErrorType.PARSER, UserLayerException.ErrorType.INVALID_FORMAT); } finally { if (store != null) { store.dispose(); } } }  @Override SimpleFeatureCollection parse(File file, CoordinateReferenceSystem sourceCRS,
            CoordinateReferenceSystem targetCRS); @Override String getSuffix(); static final String SUFFIX; }
@Test public void testKenroAlueMaarajat() throws URISyntaxException, NoSuchAuthorityCodeException, ServiceException, FactoryException { File file = new File(getClass().getResource("kenro_alue_maarajat.MIF").toURI()); MIFParser parser = new MIFParser(); SimpleFeatureCollection fc = parser.parse(file, null, CRS.decode("EPSG:2393", true)); assertEquals(2, fc.size()); SimpleFeatureIterator it = fc.features(); try { SimpleFeature f = it.next(); Polygon geom = (Polygon) f.getDefaultGeometry(); assertEquals(5, geom.getNumPoints()); assertEquals(0, geom.getNumInteriorRing()); LineString ext = geom.getExteriorRing(); Coordinate c; c = ext.getCoordinateN(0); assertEquals(3644472.125, c.x, 1e-7); assertEquals(7289630.034, c.y, 1e-7); c = ext.getCoordinateN(1); assertEquals(3644097.725, c.x, 1e-7); assertEquals(7293078.173, c.y, 1e-7); f = it.next(); MultiPolygon mp = (MultiPolygon) f.getDefaultGeometry(); assertEquals(49 + 5, mp.getNumPoints()); assertEquals(2, mp.getNumGeometries()); geom = (Polygon) mp.getGeometryN(1); assertEquals(0, geom.getNumInteriorRing()); ext = geom.getExteriorRing(); c = ext.getCoordinateN(0); assertEquals(3383004.736, c.x, 1e-7); assertEquals(6672746.505, c.y, 1e-7); c = ext.getCoordinateN(1); assertEquals(3382883.26, c.x, 1e-7); assertEquals(6675036.999, c.y, 1e-7); } finally { it.close(); } }