Hi Mark, I need to read it slowly and after it, I will decide wich option to choose. Thanks a lot
José 2007/2/7, mark2atsafe <[EMAIL PROTECTED]>:
Hi Jose, For a newcomer you are certainly starting out with an interesting problem. I think part of the decision will depend on how often you are going to need to translate these files, and if you have any programming or development skills. Obviously the more you need to do this translation, the more effort it is worth putting into the setup, and programming skills will also determine the approach to take. Anyway - I'm not convinced that converting to XML would make the task that much easier. Unless you can create it in a standard format, you'd need to create an xfmap file too to have FME read the data. As for a custom format - yes these are great when you need to view the data in a third-party application that supports FME (eg ArcGIS) or when you read the data prior to carrying out some other FME transformations. But I see your need as being a simple translation, OBJ to xxxx, in which case a custom format isn't necessarily an extra benefit. A workspace would be just as easy, and you can upgrade it to a custom format later on. So how do you translate the data in a workspace? Well, I can see a number of potential methods. The problem is that FME reads one line at a time from the file, so you have to use some trickery in a format like this where one feature spans several lines of text. 1) The first method I'd suggest is using global variables. For example, you read the data as a text file. You run this through Global Variable and Tester transformers. GlobalVariableRetriever (retrieve geometryFlag) Tester (geometryFlag = 1) False - Tester (line starts with GEOMETRY) True - GlobalVariableSetter (set geometryFlag = 1) False - do nothing True - AttributeClassifier Numeric - 2DPointReplacer (it's a coordinate) Alphabetic - GlobalVariableSetter (flag = 0) In other words the line marked GEOMETRY sets the geometry flag (variable) so that the next features are treated as geometry. After the last coordinate, reset the global variable to 0 and keep checking for the next geometry. Each feature is given an ID (another global). Each coordinate can be turned into a point. PointConnector can join the points together (stopping where ID is different). 2) A second method would be to read the features and apply an ID number. Test for the line GEOMETRY again and when this happen increment the ID number. Then each 'feature' is tagged with a unique ID. Then use an Aggregator to merge these all into a list. Count the elements in the list (=x), create x copies of the feature (with a Cloner), and demote copy #y using the ListIndexer on the cloner copy ID number. Then you have a feature for each coordinate. Create a point for each (2dpointreplacer) and use the PointConnector again (again breaking at the change of feature ID) 3) A final method would be to process the data with TCL. This is slightly easier for the methodology since you can make attributes that contain the previous records - instead of having to store them as global variables. It does rely more on programming skills though. OK - I hope this helps. Obviously these are only starting points, and aren't a complete solution. Sorry it's such a long email, but it's a relatively complex task you need to carry out. The best example of this I can find on fmepedia relates to reading a CSV file with a somewhat disordered structure. It's not entirely the same, but it does show how to use global variables and lists. http://www.fmepedia.com/index.php/CSV_Reader_Workspace_3 If you need any assistance with this then we can help on the group, but Safe also has a Solutions Assistance program you might want to consider. It's a way of getting support and advice on a custom solution such as this. http://www.safe.com/services/solution-assistance/index.php Regards, Mark Mark Ireland, Senior Product Specialist Safe Software Inc. Surrey, BC, CANADA [EMAIL PROTECTED] <support%40safe.com> http://www.safe.com Solutions for Spatial Data Translation, Distribution and Access --- In [email protected] <fme%40yahoogroups.com>, "gilrincon" <[EMAIL PROTECTED]> wrote: > > Hello, > > I need to translate some files with an own format, called OBJ (in > ascii), to FFS format (or Smallworld Swaf, GML...). I would like to > know which is the best way to do it. Should I create a custom format?, > Should I previously convert the OBJ file to a XML by means of an > script?, ... > I am newcomer to FME and any help will be much appreciated. > > Thanks in advance, > > Jose Gil > > PD: The two following texts are: a simple example of an OBJ file and a > fragment of the OBJ format specifications: > > SIMPLE EXAMPLE OF AN OBJ FILE: > > HEADER > VERSION 1.0 > UNITS m > SYS_COORD UTM > DATE_FILE 27/12/2006 > PROJECT_NAME Exportacio gis Historica 20061227 > COMPANY_NAME A.P.B. > DATA_ADQUISITION_METHOD DIGIT > TOTAL_OBJECT 2 > XY_MAX > COORD 2147000.00 2147000.00 > XY_MIN > COORD 0.00 0.00 > END_HEADER > > METADATA > END_METADATA > > OBJECT cable_teleferic > OBJHEADER > ACTION EXPORT > DATE 20061227 > BOUNDS 430883.12 580480.43 432173.07 > 580710.07 > END_OBJHEADER > KEY_FIELD apb_id 1 > GEOMETRY cable_teleferic > CHAIN > SECTOR > COORD 432173.07 580710.07 > COORD 431528.10 580595.25 > COORD 430883.12 580480.43 > END_SECTOR > END_CHAIN > END_OBJECT > OBJECT cable_teleferic > OBJHEADER > ACTION EXPORT > DATE 20061227 > BOUNDS 430884.70 580471.57 432174.65 > 580701.21 > END_OBJHEADER > KEY_FIELD apb_id 2 > GEOMETRY cable_teleferic > CHAIN > SECTOR > COORD 432174.65 580701.21 > COORD 431529.67 580586.39 > COORD 430884.70 580471.57 > END_SECTOR > END_CHAIN > END_OBJECT > END_FILE > > AND THIS IS PART OF THE OBJ FORMAT SPECIFICATIONS: > > <header> ::= HEADER > VERSION <number of version> > > UNITS <km> | <m> | <cm> | <mm> > SYSCOORD <utm> | <geo> | <port> > DATE_FILE DD/MM/AAAA > PROJECT_NAME Project Name > COMPANY Company name > [ DATA_ADQUISITION_METHOD <digi> | <photo> | > <topo> ] > > TOTAL_OBJECT <value> > XY_MAX <coord> > XY_MIN <coord> > END_HEADER > <metadata> ::= METADATA > > [<creation_metadata>] > > [<drescription_metadata>] > > END_METADATA > > <creation_metadata> ::= CREATION > (codi_magik).... > END_CREATION > > <description_metadata> ::= DESCRIPTION > (descripció taules).... > END_DESCRIPTION > > <object> ::= OBJECT <class name> > > [<objheader>] > <key_field>* > > [<field>*] > > [<geometry>*] > > [<dataless>*] > END_OBJECT > > <objheader> ::= OBJHEADER > ACTION INSERT|UPDATE|DELETE|EXPORT|HISTORIC > > DATE yyyymmdd > BOUNDS xmin,ymin,xmax,ymax > END_OBJHEADER > > <key_field> ::= KEY_FIELD <field_name> > <key_value> > > <field> ::= basic_field | basic_field field_seqs > > <basic_field> ::= FIELD <field_name> <value> > > <field_seqs> ::= field_seq | field_seq field_seqs > > > <field_seq> ::= FIELD_SEQ <value> > > <geometry> ::= GEOMETRY <geometry_name> <geom_data> > > <geom_data> ::= <point> | <chain> | <text> | <area> >
