Class AreaFileFactory
- java.lang.Object
-
- edu.wisc.ssec.mcidas.AreaFileFactory
-
public final class AreaFileFactory extends java.lang.ObjectUtility class for creatingAreaFileinstances. This class handles subsetting local files using urls whereas theAreaFileconstructors do not.No instances of this class can be created.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.StringcalIntToStr(int cal)Calibration int to string.static intcalStrToInt(java.lang.String cal)String to calibration int.static voidcopyAreaFile(java.lang.String source, java.lang.String outputFile)Copy an area file from one place to anotherstatic voidcopyAreaFile(java.lang.String source, java.lang.String outputFile, boolean verbose)Copy an area file from one place to anotherstatic AreaFilegetAreaFileInstance(java.lang.String src)Create an initializedAreaFileinstance.static AreaFilegetAreaFileInstance(java.lang.String fpath, int startLine, int numLines, int lineMag, int startElem, int numEles, int eleMag, int band)static AreaFilegetAreaFileInstance(java.net.URL url)Create an initializedAreaFileinstance.static java.lang.StringmakeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b)Construct a url query string for subsetting a local file.static java.lang.StringmakeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b, int c)Construct a url query string for subsetting a local file.static java.lang.StringmakeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b, java.lang.String c)Construct a url query string for subsetting a local file.static java.net.URLmakeLocalSubsetURL(java.lang.String fpath, int sl, int nl, int lm, int se, int ne, int em, int b, java.lang.String u)Construct aURLfor subsetting a local file.
-
-
-
Method Detail
-
calStrToInt
public static final int calStrToInt(java.lang.String cal)
String to calibration int.- Parameters:
cal- calibration type string- Returns:
- calibration type integer, Calibrator.CAL_NONE if unknown
-
calIntToStr
public static final java.lang.String calIntToStr(int cal)
Calibration int to string.- Parameters:
cal- calibration type- Returns:
- calibration type string, raw if unknown
-
makeLocalQuery
public static final java.lang.String makeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b)Construct a url query string for subsetting a local file.- Parameters:
sl- starting line number.nl- number of lines.lm- line magnification.se- starting element.ne- number of elements.em- element magnification.b- band number.- Returns:
- "?band=B&linele=SL SE&size=NL NE&mag=LM EM"
-
makeLocalQuery
public static final java.lang.String makeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b, int c)Construct a url query string for subsetting a local file.- Parameters:
sl- starting line number.nl- number of lines.lm- line magnification.se- starting element.ne- number of elements.em- element magnification.b- band number.c- calibration type- Returns:
- "?band=B&linele=SL SE&size=NL NE&mag=LM EM"&unit=C;
-
makeLocalQuery
public static final java.lang.String makeLocalQuery(int sl, int nl, int lm, int se, int ne, int em, int b, java.lang.String c)Construct a url query string for subsetting a local file.- Parameters:
sl- starting line number.nl- number of lines.lm- line magnification.se- starting element.ne- number of elements.em- element magnification.b- band number.c- calibration type as a string- Returns:
- "?band=B&linele=SL SE&size=NL NE&mag=LM EM"&unit=C;
-
makeLocalSubsetURL
public static final java.net.URL makeLocalSubsetURL(java.lang.String fpath, int sl, int nl, int lm, int se, int ne, int em, int b, java.lang.String u) throws java.net.MalformedURLExceptionConstruct aURLfor subsetting a local file.- Parameters:
fpath- canonical path to an area file.sl- starting line number.nl- number of lines.lm- line magnification.se- starting element.ne- number of elements.em- element magnification.b- band number.u- calibration unit- Returns:
- a string of the format
"file://FPATH?band=B& linele=SL SE&size=NL NE&mag=LM EM"&unit=U - Throws:
java.net.MalformedURLException- bad URL specification
-
getAreaFileInstance
public static final AreaFile getAreaFileInstance(java.lang.String src) throws AreaFileException, AddeURLException
Create an initializedAreaFileinstance. First, an attempt is made to create aURLfromsrc, if an error occurrs, meaningsrcis not a valid url,srcis interpreted as a file path.- Parameters:
src- A relative or canonical path to a local file as a string or a string representation of a url appropriate for creating anAreaFileinstance. For more information on urls appropriate for creatingAreaFileinstances seegetAreaFileInstance(URL).URLs containing encoded characters in their query strings will be decoded before parsing.
- Returns:
- an initialized, possibly subsetted, instance
- Throws:
AreaFileException- on any error constructing the instance.AddeURLException- If the source is a URL and the query string is not formatted correctly.
-
getAreaFileInstance
public static final AreaFile getAreaFileInstance(java.net.URL url) throws AddeURLException, AreaFileException
Create an initializedAreaFileinstance.A url appropriate for creating an instance will have a protocol of either
addefor remote ADDE data orfilefor files on the local disk. Information on consructing ADDE urls can be found in theAddeURLConnectionclass.A local file url may either be a standard file url such as file:///<absolute file path> or it may specify subsetting information. If specifying subsetting information, the url can contain the following parameters from the ADDE image data url specification with the specified defaults:
NAME DEFAULT linele - 0 0 a Must be used with size. NOTE: only type 'a' is supported at this time size - 0 0 Must be used with linele. mag - 1 1 Only with linele and size, but not required. band - 1 Can be used separately, not required. unit - RAW Calibration typeA file url might look like:file://<abs file path>?linele=10 10&band=3&mag=-2 -4&size=500 500&unit=BRIT
URLs containing encoded characters in their query strings will be decoded before parsing.
- Parameters:
url- - the url as described above- Returns:
- an initialized, possibly subsetted, instance
- Throws:
AreaFileException- on any error constructing the instance.AddeURLException- if the query string is not a valid ADDE query stirng.
-
getAreaFileInstance
public static final AreaFile getAreaFileInstance(java.lang.String fpath, int startLine, int numLines, int lineMag, int startElem, int numEles, int eleMag, int band) throws AreaFileException
- Parameters:
fpath- the path to the filestartLine- the starting image linenumLines- the total number of lines to returnlineMag- the line magnification. Valid values are >= -1. -1, 0, and 1 are all taken to be full line resolution, 2 is every other line, 3 every third, etc...startElem- the starting image elementnumEles- the total number of elements to returneleMag- the element magnification. Valid values are >= -1. -1, 0, and 1 are all taken to be full element resolution, 2 is every other element, 3 every third, etc...band- the 1-based band number for the subset, which must be present in the directory blocks band map or -1 for the first band- Returns:
- the AreaFile instance
- Throws:
AreaFileException
-
copyAreaFile
public static void copyAreaFile(java.lang.String source, java.lang.String outputFile) throws AddeURLException, AreaFileExceptionCopy an area file from one place to another- Parameters:
source- source file or ADDE urloutputFile- name of the output file- Throws:
AreaFileException- on any error constructing the instance.AddeURLException- If the source is a URL and the query string is not formatted correctly.
-
copyAreaFile
public static void copyAreaFile(java.lang.String source, java.lang.String outputFile, boolean verbose) throws AddeURLException, AreaFileExceptionCopy an area file from one place to another- Parameters:
source- source file or ADDE urloutputFile- name of the output fileverbose- true to print out status messages- Throws:
AreaFileException- on any error constructing the instance.AddeURLException- If the source is a URL and the query string is not formatted correctly.
-
-
DMelt 3.0 © DataMelt by jWork.ORG