My feature have a feature type name... But how to associate a extern schema with my new feature collection ?
Florian -----Message d'origine----- De : Jody Garnett [mailto:[EMAIL PROTECTED] Envoyé : vendredi 27 avril 2007 22:53 À : Husson Florian Cc : Justin Deoliveira; geotools-gt2-users@lists.sourceforge.net Objet : Re: [Geotools-gt2-users] Help to create a feature from an other That line says: > e = > output.findElement(f.getFeatureType().getTypeName()); So I think your feature either does not have a feature type name.... either that or the schema you are using does not contain an element that matches the name of the feature you are trying to write out. You are using an xml parser/encoder that has not been documented very well ... my best recommendation (other then to fix your feature) is to switch to trunk and try out the parser Justin is working on.... Jody Husson Florian wrote: > Hi, > > Here is the problem : > > java.lang.NullPointerException > at > org.geotools.xml.gml.GMLComplexType$AbstractFeatureCollectionType.encode(GMLComplexTypes.java:4778) > at > org.geotools.xml.DocumentWriter.writeFragment(DocumentWriter.java:310) > at > org.geotools.xml.DocumentWriter.writeDocument(DocumentWriter.java:208) > > I use the library 2.3.1. > > Thanks, > Florian. > > > > > -----Message d'origine----- > De : Justin Deoliveira [mailto:[EMAIL PROTECTED] Envoyé : > mercredi 25 avril 2007 18:30 À : Husson Florian Cc : > geotools-gt2-users@lists.sourceforge.net > Objet : Re: [Geotools-gt2-users] Help to create a feature from a other > > Hi, > > The code to copy the feature looks fine. A couple of questions. Exactly what > kind of problem are you having encoding gml. Are there any exceptions you can > include for us? > > -Justin > > Husson Florian wrote: > >> Hello, >> >> I have a feature with 4 attributes and I want to add a new attribute. >> So I created a new feature with the same attributes and adding the >> new attribute : >> >> >> //Feature with its attributes >> Feature f; >> AttributeType[] att = f.getFeatureType().getAttributeTypes(); >> >> >> //Attributes of new Feature >> AttributeType[] types = new AttributeType[att.length+1]; >> >> >> //Set the the new Feature's attributes with the old one for (int i >> =0; i<att.length ; i++){ types[i] = >> AttributeTypeFactory.newAttributeType(att[i].getName(),att[i].getType >> ( >> )); >> } >> types[types.length-1]=AttributeTypeFactory.newAttributeType("levelOfP >> r >> otect", >> Double.class); >> >> >> //Create new FeatureType >> FeatureType testSchema = FeatureTypeBuilder.newFeatureType(types, >> "testSchema"); >> >> >> //Fill the attributes >> Object[] attributes = new Object[types.length]; attributes[0] = >> f.getDefaultGeometry(); attributes[1] = f.getAttribute(1).toString(); >> attributes[2] = f.getAttribute(2).toString(); attributes[3] = >> Integer.parseInt(f.getAttribute(3).toString()); >> attributes[4] = f.getAttribute(4).toString(); attributes[5] = new >> Double(12); >> >> >> //Create the feature >> Feature result = testSchema.create(attributes); >> >> >> But I have a problem to display that in GML. >> Why...? >> >> Thank you. >> Le contenu de ce mél et de ses pièces jointes est destiné à l'usage >> exclusif du >> (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de >> réception de ce mél par erreur, le signaler à son expéditeur et ne >> pas en divulguer le contenu. >> L'absence de virus a été vérifié à l'émission du message. Il >> convient néanmoins de vérifier l'absence de contamination à sa réception. >> >> The contents of this email and any attachments are confidential. They >> are intended for the named recipient(s) only. If you have received >> this email in error please notify the system manager or the sender >> immediately and do not disclose the contents to anyone or make copies. >> eSafe scanned this email for viruses, vandals and malicious content. >> >> >> --------------------------------------------------------------------- >> - >> -- >> >> --------------------------------------------------------------------- >> - >> --- This SF.net email is sponsored by DB2 Express Download DB2 >> Express C - the FREE version of DB2 express and take control of your >> XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> >> >> --------------------------------------------------------------------- >> - >> -- >> >> _______________________________________________ >> Geotools-gt2-users mailing list >> Geotools-gt2-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > > > -- > Justin Deoliveira > The Open Planning Project > http://topp.openplans.org > ********************************************************************** > ************************ Le contenu de ce mél et de ses pièces jointes > est destiné à l'usage exclusif du > (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de > réception de ce mél par erreur, le signaler à son expéditeur et ne pas en > divulguer le contenu. > L'absence de virus a été vérifié à l'émission du message. Il convient > néanmoins de vérifier l'absence de contamination à sa réception. > The contents of this email and any attachments are confidential. They > are intended for the named recipient(s) only. If you have received > this email in error please notify the system manager or the sender > immediately and do not disclose the contents to anyone or make copies. > eSafe scanned this email for viruses, vandals and malicious content. > ********************************************************************** > ************************ > > > ---------------------------------------------------------------------- > --- This SF.net email is sponsored by DB2 Express Download DB2 Express > C - the FREE version of DB2 express and take control of your XML. No > limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ********************************************************************************************** Le contenu de ce mél et de ses pièces jointes est destiné à l'usage exclusif du (des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception de ce mél par erreur, le signaler à son expéditeur et ne pas en divulguer le contenu. L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins de vérifier l'absence de contamination à sa réception. The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. eSafe scanned this email for viruses, vandals and malicious content. ********************************************************************************************** ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users