Directly read road data from the MIF File

Source: Internet
Author: User
String File =   @" C: \ Inetpub \ wwwroot \ ssweb \ node \ road. MIF " ; // Load data and use an absolute path (a separate integrated node layer)
Streamreader SR =   New Streamreader (File );
String Nextline, stmp;
Long Ntmp, mtmp;
Ntmp = Mtmp =   0 ;
Tnode fnode, cNode;
Fnode = CNode =   Null ;
While (Nextline = Sr. Readline ()) ! =   Null )
{
Stmp = Nextline. Trim ();
If (Stmp. Length >   14   && Stmp. substring ( 0 , 14 ). Compareto ( " Pline multiple " ) =   0 )
{
Ntmp =   0 ;
Ntmp = Convert. toint32 (stmp. substring ( 14 ));
For ( Long I = 0 ; I < Ntmp; I ++ )
{
If (Nextline = Sr. Readline ()) =   Null )
Break ;

Fnode = CNode =   Null ;
Mtmp =   0 ;
Stmp = Nextline. Trim ();
Mtmp = Convert. toint32 (stmp );
For ( Long N = 0 ; N < Mtmp; n ++ )
{
If (Nextline = Sr. Readline ()) =   Null )
Break ;

Stmp = Nextline. Trim ();
String Delimstr =   "   " ;
Char [] Delimiter = Delimstr. tochararray ();
String [] Atmp = Stmp. Split (delimiter, 2 );

Fnode = CNode;
CNode =   New Tnode ();
CNode. SX = Convert. todouble (atmp [ 0 ]);
CNode. Sy = Convert. todouble (atmp [ 1 ]);
CNode. addchild (fnode );
If (Fnode ! =   Null )
fnode. addchild (cNode);
mdatalist. add (fnode);
mdatalist. add (cNode);
}
}
}
Else   If (Stmp. Length >   4   && Stmp. substring ( 0 , 5 ). Compareto ( " Pline " ) =   0 )
{
Fnode = CNode =   Null ;
Ntmp =   0 ;
Ntmp = Convert. toint32 (stmp. substring ( 5 ));
For ( Long I = 0 ; I < Ntmp; I ++ )
{
If (Nextline = Sr. Readline ()) =   Null )
Break ;

Stmp = Nextline. Trim ();
String Delimstr =   "   " ;
Char [] Delimiter = Delimstr. tochararray ();
String [] Atmp = Stmp. Split (delimiter, 2 );

Fnode = CNode;
CNode =   New Tnode ();
CNode. SX = Convert. todouble (atmp [ 0 ]);
CNode. Sy = Convert. todouble (atmp [ 1 ]);
CNode. addchild (fnode );
If (Fnode ! =   Null )
Fnode. addchild (cNode );

Mdatalist. Add (fnode );
Mdatalist. Add (cNode );
}
}
}
Sr. Close ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.