You can get away with it just fine :-) But it is not very usual ... I
assume you mean you do not want to build a seperate attribute for every
possibly occuring attribute?
The concept of a Feature is very much like a java.util.Map with a strict
list of Keys that are defined up front. What is your domain that you
have a varying list of attributes?
You may (or may not) of noticed that the "xpath" expressions used by
PropertyName can rip into your attrMap and grab the values out.
So an expression like ff.property("attrMap/key1") should work; allowing
you to use your map entries when styling or when selecting data...
So back on track - here are the two ways the feature model is supposed
to help you handle this kind of thing:
- take a look at their data and make a FeatureType reflecting what keys
are in use today; making an attribute for each key. If not all features
have the values then some of the attributes would be marked optional.
- provide associations (possibly 0..* many associations) to a
ComplexAttribute containing key a value pair. This would reproduce the
concept of a Map.Entry using the feature model classes.
Note that not all schools of thought requiring you to group your
features into types.
If they really have nothing in common you could just make each feature
one at a time reflecting what data you have. The idea is that for a
feature called the "Effel Tower" there is really only one. Now you could
represent that as a member of "Landmarks" or you could just have it
stand on its own. You can still use a FeatureType to let a program know
about your attributes (ie similar to map.keySet()) but the FeatureType
would only have one Feature.
In programing speak we call this idea a singleton; you can use it for
map mapping if you want.
Jody
Julian Hagenauer wrote:
> Hi,
> i am a bit confused.
> Is is ok or not, to do something like:
> SimpleTypeBuilder builder = new SimpleTypeBuilder();
> builder.setName( "testType" );
> builder.setNamespaceURI( "http://www.geotools.org/" );
> builder.setSRS( "EPSG:4326" );
> //add attributes
> builder.add( "attrMap", Map.class );
>
> It seem's to work fine, but i remember, that it might not be ok to use maps
> as attributes.
> The problem is, that i have a varying list of attributes, and i don't want to
> build a seperate featuretype for every possibly occuring attribute.
>
> Sincerely,
> Julian
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users