Here is some very old and simple C code to give you some ideas of you can
approach the problem.  It is used to read a fixed global map data base and
convert it to DX format.  It could run as a standalone program, in which
you save the results from stdout to a file, or as a DX Import filter.  The
I/O is in ASCII so that you can more easily see how to do the conversion.

I hope this helps.

--------------------------

/*    Program to read WDB I in converted ASCII format.  It contains 109928
points as latitude-longitude ordered pairs for world coastlines and
political boundaries.  The file contains 1247 "records" implying
1247 contiguous lines, each of which contains from 2 to 3949 points,
totalling 109928.

 The program will create a dx file defining a single field called
 "WDB I" with 1247 lines, each of which corresponds to one of the
 lines of the data base.  Each line is composed of positions and
 line segments as connections.
*/

#include <stdio.h>
#include <string.h>

FILE *input;

main ()
{

/* define local variables */

int line;
int point;
int total_points;
int points_per_line;
int total_segments;
float latitude;
float longitude;
float lat[109228];
float lon[109928];
int start_segment[109928];
int end_segment[109928];

/* get file and loop for each line in the file */

line = 0;
total_points = 0;
total_segments = 0;
input = fopen("wdbi.ascii","r");

while (fscanf(input, "%d\n", &points_per_line) != EOF) {
 line++;
 /* for each line collect the positions and define the connections.
    The positions are the points that are read in.  The connections
    are lines.  The number of positions/connections are read in first. */

 /* construct a connections list for the current line */

 for (point=0; point < points_per_line - 1; point++) {
  start_segment[total_segments] = total_points + point;
  end_segment[total_segments] = total_points + point + 1;
  total_segments++;
  }

 /* collect each of the positions of the current line */

 for (point=0; point < points_per_line; point++) {
  fscanf(input, "%f %f\n", &latitude, &longitude);
  lat[total_points] = latitude;
  lon[total_points] = longitude;
  total_points++;
  }
 }

/* define positions component from the saved points */

printf("object \"points\" class array type float rank 1 shape 2 items
109928 data follows\n");
for (point=0; point < 109928; point++) {
 printf("%f %f\n", lat[point], lon[point]);
 }
printf("attribute \"dep\" string \"positions\"\n");

/* define connections component from the saved connections lists */

printf("object \"segments\" class array type int rank 1 shape 2 items %d
data follows\n", total_segments);
for (point=0; point < total_segments; point++) {
 printf("%d %d\n", start_segment[point], end_segment[point]);
 }
printf("attribute \"element type\" string \"lines\"\n");

printf("attribute \"ref\" string \"positions\"\n");

/* define map object of lines */

printf("object \"WDB I\" class field\n");
printf("component \"positions\" value \"points\"\n");
printf("component \"connections\" value \"segments\"\n");
printf("end\n");

fclose(input);
}

--------------------------


Marilyn Menecucci Ibanez <[EMAIL PROTECTED]>@opendx.watson.ibm.com on
07/10/2003 08:16:50 AM

Please respond to [email protected]

Sent by:    [EMAIL PROTECTED]


To:    [email protected]
cc:
Subject:    Re: [opendx-users] Boundary Countor





   Hi, Lloyd


   I need to see similar approach in C. If you can to
send for me, I would be very greatfull.





                          Regards,



Ibanez, Marilyn M.
INPE - Instituto Nacional de Pesquisas Espaciais
Brazil









--- Lloyd A Treinish <[EMAIL PROTECTED]> escreveu: >
>
>
>
> That's also what I was suggesting.
>
> Marilyn, the approach in Bodo's code should work for
> typical boundary data,
> although adjustments for the physical format may be
> necessary.  If you need
> to see a similar approach in C, I can send you an
> example.
>
>
> Bodo Ritter
> <[EMAIL PROTECTED]>@opendx.watson.ibm.com on
> 07/07/2003
> 03:47:24 PM
>
> Please respond to [email protected]
>
> Sent by:    [EMAIL PROTECTED]
>
>
> To:    [email protected]
> cc:
> Subject:    Re: [opendx-users] Boundary Countor
>
>
>
> Hi Marilyn,
> you could simply convert your ASCII political
> boundary layer file to
> DX-format, then
> IMPORT the converted file in your network, add color
> (if you didn't do this
> at the
> file creation stage) and put it together with the
> rest of your illustration
> into
> COLLECT before you pass it to IMAGE or DISPLAY.
> Obviously your converted boundary data should be in
> the same spatial
> dimensions
> (e.g. latitude/longitude coordinates) as the rest of
> the fields; otherwise
> you
> may need some geographical projection tools/macros,
> which are available via
> the
> DX bonus pack.
> If you don't know how to convert your boundary
> information to DX format, I
> have
> included a small and rather basic FORTRAN program
> that I used to convert
> coastline
> information to DX format. It simply reads
> latitude/longitude information
> from a file
> and puts it back in a form suitable for IMPORT in
> native DX.
>
> Regards,
> Bodo
>
>
> On Mon, Jul 07, 2003 at 11:31:53AM -0300, Marilyn
> Meneucci Ibañez wrote:
> >  Hi, users
> >
> >
> >   I am sorry. I think that not explain well.
> >   I would be very greatfull if you can help me
> again.
> >   I have data that form a politic boundary in a
> > country (closed polygon) and data that que form an
> > image. I need overlay closed poligon on image.
> What
> > fromat of the data wiil use?
> >    I am sending the files anexed.
> >
> >
> >
> >
> >                            Thank you very much,
> >
> >
> > Ibanez, Marilyn M.
> > INPE - Instituto Nacional de Pesquisas Espaciais.
> > Brazil
> >
> >
> >
> >
> > =====
> > Marilyn Menecucci Ibañez
> >
> >
>
_______________________________________________________________________
> > Yahoo! Mail
> > Mais espaço, mais segurança e gratuito: caixa
> postal de 6MB, antivírus,
> proteção contra spam.
> > http://br.mail.yahoo.com/
>
>
>
>
> --
> Adress:    Bodo Ritter
>            c/o Deutscher Wetterdienst
>            Postfach 100465
>            63004 Offenbach/Main
>
> Tel.  :    +49-69-8062-2703
> Fax   :    +49-69-8062-3721
>  email :    [EMAIL PROTECTED]
>
>
>

_______________________________________________________________________
Yahoo! Mail
Mais espaço, mais segurança e gratuito: caixa postal de 6MB, antivírus,
proteção contra spam.
 http://br.mail.yahoo.com/

Reply via email to