
com.github.nikolaybespalov.gtozi.OziMapFormat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gt-ozi Show documentation
Show all versions of gt-ozi Show documentation
GeoTools plugin that allows you to read OziExplorer spatial reference file(.MAP) without using
GDAL/OziApi or any other environment dependencies.
package com.github.nikolaybespalov.gtozi;
import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
import org.geotools.coverage.grid.io.AbstractGridFormat;
import org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams;
import org.geotools.data.DataSourceException;
import org.geotools.factory.GeoTools;
import org.geotools.factory.Hints;
import org.opengis.coverage.grid.Format;
import org.opengis.coverage.grid.GridCoverageWriter;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.geotools.util.logging.Logging.getLogger;
@SuppressWarnings("WeakerAccess")
public final class OziMapFormat extends AbstractGridFormat implements Format {
private static final Logger LOGGER = getLogger(OziMapFormat.class);
public OziMapFormat() {
writeParameters = null;
mInfo = new HashMap<>();
mInfo.put("name", "Ozi");
mInfo.put("description", "OziExplorer Map File Format");
mInfo.put("vendor", "nikolaybespalov");
mInfo.put("version", "0.1");
mInfo.put("docURL", "https://github.com/nikolaybespalov/gt-ozi");
}
@Override
public boolean accepts(Object source, Hints hints) {
if (source == null) {
LOGGER.severe("input should not be null");
return false;
}
try {
AbstractGridCoverage2DReader reader = getReader(source, hints);
if (reader != null) {
reader.dispose();
return true;
}
} catch (Throwable t) {
LOGGER.log(Level.SEVERE, t.getLocalizedMessage(), t);
}
return false;
}
@Override
public AbstractGridCoverage2DReader getReader(Object o) {
return getReader(o, GeoTools.getDefaultHints());
}
@Override
public AbstractGridCoverage2DReader getReader(Object source, Hints hints) {
if (source == null) {
LOGGER.severe("input should not be null");
return null;
}
try {
return new OziMapReader(source);
} catch (DataSourceException e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
return null;
}
@Override
public GridCoverageWriter getWriter(Object o) {
return getWriter(o, GeoTools.getDefaultHints());
}
@Override
public GridCoverageWriter getWriter(Object o, Hints hints) {
return null;
}
@Override
public GeoToolsWriteParams getDefaultImageIOWriteParameters() {
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy