Hello again Jody

I was exploring a little more this task, and came along with some other questions:

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? - In this case, should we add a CommonFactoryFinder.getStyleFactory2 method, as was done with the FilterFactory case, so that classes such as DuplicatingStyleVisitor can instantiate it?

2. How should we deal with default values / initialization of symbolizer parameters (e.g., stroke, uom, etc)? - Current practice is to initialize everything to null by default, and the getter methods simply return null in that case (I find this a little strange, by the way) - Should we change that to return default values in the getter methods whenever the parameter is null?
- Should StyleFactoryImpl2 set default values for null parameters?
- Should we not accept null values in the initialization?

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)

Cheers
Milton

Milton Jonathan wrote:
Hey Jody

I have created a StyleFactoryImpl2 for you (on trunk); and started in
on the implementation. If we can sort out everything on this class we
will have little danger of breaking others.

OK!

You will find I have cleaned up some of the classes that were
providing difficulty; and implemented a few missing ones.

OK, but we still have those two pending issues:
- Which Stroke to use when instantiating a (e.g.Line)SymbolizerImpl? Should we convert from opengis to geotools? - In this Impl, should we change the member String geometryName to a PropertyName? In that case, in StyleFactoryImpl2.lineSymbolier() we would check the Expression geometry parameter to see if it is indeed a PropertyName?

Cheers
Milton


--

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 * 
 *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
 *    
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.styling;

import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;


/**
 * Defines the Units of Measure (UOMs) specified by the OGC SE standard. Each
 * entry in this enum provides both the Java Unit for the given UOM and the
 * corresponding String that is defined by the SE standard.
 */
public enum UnitOfMeasure {

	METRE(SI.METER, "http://www.opengeospatial.org/se/units/metre";),
	FOOT(NonSI.FOOT, "http://www.opengeospatial.org/se/units/foot";),
	PIXEL(NonSI.PIXEL, "http://www.opengeospatial.org/se/units/pixel";);
	

	private String seString;
	private Unit<?> unit;

	/**
	 * Internal constructor: specifies the UOM passing a specific Java Unit and
	 * the corresponding SE string.
	 * 
	 * @param unit
	 *            a Java Unit (e.g., <code>SI.METER</code>).
	 * @param seString
	 *            a String that follows the OGC SE specification.
	 */
	private UnitOfMeasure(Unit<?> unit, String seString) {
		this.unit = unit;
		this.seString = seString;
	}

	@Override
	public String toString() {
		return seString;
	}

	/**
	 * Returns the String defined by the OGC SE specification for the unit of
	 * measure.
	 * 
	 * @return a String that follows the OGC SE specification
	 */
	public String getSEString() {
		return seString;
	}

	/**
	 * Returns the Java Unit that corresponds to the unit of measure.
	 * 
	 * @return a Java Unit (e.g., <code>SI.METER</code>).
	 */
	public Unit<?> getUnit() {
		return unit;
	}

	/**
	 * Returns the appropriate UnitOfMeasure for a given OGC SE standard string.
	 * 
	 * @param seString
	 *            a String that follows the OGC SE specification.
	 * @return the corresponding UnitOfMeasure.
	 * @throws IllegalArgumentException
	 *             if the provided String is not a valid OGC SE value.
	 */
	public static UnitOfMeasure getUnitOfMeasure(String seString)
			throws IllegalArgumentException {
		for (UnitOfMeasure uom : UnitOfMeasure.values()) {
			if (uom.getSEString().equals(seString))
				return uom;
		}
		throw new IllegalArgumentException("'" + seString
				+ "' is not a valid OGC SE standard Unit of Measure");
	}

	/**
	 * Returns the appropriate UnitOfMeasure for a given Java Unit.
	 * 
	 * @param unit
	 *            a Java Unit (e.g., <code>SI.METER</code>).
	 * @return the corresponding UnitOfMeasure.
	 * @throws IllegalArgumentException
	 *             if the provided Unit is not part of the OGC SE specification.
	 */
	public static UnitOfMeasure getUnitOfMeasure(Unit<?> unit) {
		for (UnitOfMeasure uom : UnitOfMeasure.values()) {
			if (uom.getUnit().equals(unit))
				return uom;
		}
		throw new IllegalArgumentException("'" + unit
				+ "' is not a valid OGC SE standard Unit of Measure");
	}
}
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to