Graham; did you not have to look at UOM when working on the WPS bindings? It looks like we have found another place where OGC UOM does not match up with the java units class "foot" != "feet" or whaterver.
If you can remember where we made the conversion it would be good to bring the code together into one spot. Jody On Thu, Apr 16, 2009 at 12:42 AM, Milton Jonathan <[email protected]> wrote: > Hello again Jody > >>> Aside from that, I implemented a little Enum class for storing the OGC >>> definitions for UOMs (both the String expected in the .sld file and the >>> corresponding Java Unit). Do you want to take a look? (attached) >> >> That sounds fine; I seem to recall someone else doing this recently >> (in order to get around UOM for the WPS specification; so there is a >> chance we could have a single utility class for this). >> > > Well, I did find a net.opengis.wps10.UOMsType interface and UOMsTypeImpl > class, but I'm not even sure this UOM really means Unit of Measure, because > it doesn't deal with or mentions units anywhere. It simply uses some defines > in Wps10Pacakge, such as int UO_MS_TYPE__UOM = 0, etc. I don't know really > what it is, but didn't look appropriate.. > > >>> 1. How can we effectively use StyleFactoryImpl2? >>> - SEParser and DuplicatingStyleVisitor currently expect an >>> org.geotools.styling.StyleFactory interface, which DOES NOT have the new >>> factory methods. Do you think there should be a StyleFactory2 interface? >> >> Two ways: >> - replace the SEParser field with an org.opengis.style.StyleFactory >> - change StyleFactoryImpl to delegate to the StyleFactory2 >> implementation (since we cannot do multiple inheirietence). > > Simply replacing the field gives me a lot of trouble because the parser > extensively uses methods such as createExternalGraphic(String uri, String > format). I'm not sure if all of those methods can be replaced by the new > interface (if they can, then I guess this is the cleanest thing to do), but > in any case that means messing around with many methods I don't quite > understand.. > > What I found easier to do right now was Solution 2 + an extra twist: I need > org.geotools.styling.StyleFactory to have all the opengis methods (which > indeed StyleFactoryImpl has). So I just made > org.geotools.styling.StyleFactory extend org.opengis.style.StyleFactory (not > sure if there is a reason to avoid that). Then in StyleFactoryImpl, all the > opengis methods are delegated to your internal opengis StyleFactoryImpl2, as > you suggested. > > Still, not everything looks nice. I think it really odd that > SEParse.parseLineSymbolizer calls an opengis factory method (which returns > an org.opengis.style.LineSymbolizer), but needs to return an > org.geotools.style.LineSymbolizer in the end. How can he guarantee that to > be true? Maybe use a copy constructor if needed? I guess I am still a little > confused.. > > This is how the code is looking, already (trying to) deal with the issue > with the default values (I still don't know what would be default values for > name and description). What do you think? > > -- > > private LineSymbolizer parseLineSymbolizer(Node root) { > String name = null; > Expression geometry = Expression.NIL; > Description description = null; > UnitOfMeasure uom = UnitOfMeasure.PIXEL; > Stroke stroke = factory.getDefaultStroke(); > Expression offset = ff.literal(0); > > NamedNodeMap namedNodeMap = root.getAttributes(); > Node uomNode = namedNodeMap.getNamedItem(uomString); > if(uomNode != null) > uom = UnitOfMeasure.getUnitOfMeasure(uomNode.getNodeValue()); > > NodeList children = root.getChildNodes(); > final int length = children.getLength(); > for (int i = 0; i < length; i++) { > Node child = children.item(i); > > if ((child == null) || (child.getNodeType() != > Node.ELEMENT_NODE)) { > continue; > } > String childName = child.getLocalName(); > if (childName == null) { > childName = child.getNodeName(); > } > if (childName.equalsIgnoreCase(geomString)) { > geometry = ff.literal(parseGeometryName(child)); > } else if (childName.equalsIgnoreCase(strokeString)) { > stroke = parseStroke(child); > } > } > > // PROBLEMS HERE: need to convert an opengis LineSymbolizer to a > // geotools one! > org.opengis.style.LineSymbolizer symbol = > factory.lineSymbolizer(name, geometry, description, uom.getUnit(), > stroke, offset); > > if (symbol instanceof LineSymbolizer) > return (LineSymbolizer) symbol; > else > // TODO: what do we do here? use copy constructor? > return new LineSymbolizerImpl(stroke, offset, uom.getUnit(), > geometry.toString(), name, description); > > return symbol; > } > > Cheers > Milton > > -- > > Milton Jonathan > Grupo GIS e Meio Ambiente > Tecgraf/PUC-Rio > Tel: +55-21-3527-2502 > ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
