JAMISON CONLEY a écrit :
I would like to apply a JAI operation (specifically binarize at the moment) to a
GridCoverage2D. I've created a BilevelOperation with the following statement:
BilevelOperation bin = new BilevelOperation("Binarize");
How do I actually apply it though? The javadoc for OperationJAI says the entry
point is the doOperation method, but that method is protected. There isn't a
binarize option in the Operations class. I'd add it to DefaultProcessor and
access it that way, but DefaultProcessor's addOperation method is protected,
too.
Am I missing something or has what I'm looking for not been implemented yet?
If possible, I'd prefer to use 2.2.x, but can switch to 2.3.x if need be.
You can do the following steps (it should work with 2.2):
1) Create a sub-class of OperationJAI (or BilevelOperation in the specific case
of an operation
producing only two values (e.g. black/white) as output) as in the example
below. Note that
yours subclass must have a public no-argument constructor.
package org.mypackage;
public class MyOperation extends BilevelOperation {
public MyOperation() {
super("Binarize");
}
}
Creating a subclass may looks like an overkill, but you way want later to
override some
OperationJAI's methods in order to get some control on various aspects like
the output
javax.units.Unit, etc.
2) Create the following file:
META-INF/services/org.opengis.coverage.processing.Operation
and add the following line (modified for yours need) in that file:
org.mypackage.MyOperation
4) Create a JAR which contains yours operation implementation as well as the
above META-INF
directory.
5) Make sure that yours JAR is in yours classpath, and try the following:
java org.geotools.coverage.processing.DefaultProcessor
You should see yours operation in the list of known operations. Just having
yours JAR file
in the classpath is suffisient for getting Geotools coverage processor to
see it. No explicit
registration needed on the user side. Any Geotools application can take
advantage of
org.mypackage.MyOperation even if they knew nothing about this operation.
Martin.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel