Andy,
Thanks for the pointers. I have made the change and it seems to work
well. Below is a sample of one of the functions I added to the c api
in case anyone is interested (also, my C is not very good, so if
anyone wants to suggest a better method or code please let me know).
double MITAB_STDCALL
mitab_c_get_boundingbox_minx( mitab_handle handle )
{
OGREnvelope oExt;
IMapInfoFile *poFile = (IMapInfoFile *) handle;
if (poFile->GetExtent(&oExt, TRUE) == OGRERR_NONE)
{
return oExt.MinX;
}
else
return 0;
}
And the C# DllImport;
[DllImport(@"C:\Temp\MITAB\mitab-1.3.0\mitab\mitab.dll",
EntryPoint="mitab_c_get_boundingbox_minx", SetLastError=true,
CallingConvention=CallingConvention.StdCall)]
public unsafe static extern double mitab_c_get_boundingbox_minx
(IntPtr Handle);
Chris
--- In [EMAIL PROTECTED], "Canfield, Andrew"
<[EMAIL PROTECTED]> wrote:
>
> Chris,
> I don't think that it is in the C API but the info is there
because
> it's stored in one of the file headers. The function within OGR
that returns
> this info to a OGREnvelope pointer passed into the function is
called:
> TABFile::GetExtent it returns the extents of the data currently in
the tab
> file.
>
> I haven't used the C api in a very long time so perhapse this has
been
> wrapped already? If not you can either add it on your own or put
in a
> request to have it added.
>
> Since you are using C# does that mean you have Visual Studio? If
so then you
> could compile it in yourself. Any version of VC++ can compile
mitab from
> VC++6 on up to VC++2005. Just make sure you compile it as byte
code if you
> are using one of the .Net versions of Visual Studio.
> Thanks,
> Andy
>
> -----Original Message-----
> From: chris_santer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 27, 2004 6:16 AM
> To: [EMAIL PROTECTED]
> Subject: [mitab] mitab c api in C#
>
>
>
>
>
> I have successfully implemented much of the c api using C#, but I
> cannot figure out where to get the information I need to draw the
> map to the window and allow zoom in/out. I need the bounding box,
in
> world coordinates, for the entire layer. Is there a way to get
this
> information using the c api? Below is some sample code I am using
to
> retreive the X, Y coords for a point based layer:
>
> for(int iPointCounter=0;iPointCounter<iPointCount;iPointCounter++)
> {
> Point pt = new Point();
>
> dX = mitab_c_get_vertex_x(iFID, iPartCounter, iPointCounter);
> dY = mitab_c_get_vertex_y(iFID, iPartCounter, iPointCounter);
>
> pt.X = Convert.ToInt32(Convert dX here to screen coords);
> pt.Y = Convert.ToInt32(Convert dY here to screen coords);
>
> int iPenColor = mitab_c_get_pen_color(iFID);
> int iPenWidth = mitab_c_get_pen_width(iFID);
> int iPenPattern = mitab_c_get_pen_pattern(iFID);
> R = iPenColor / 65536 ;
> G = (iPenColor - R*65536) / 256 ;
> B = iPenColor - R*65536 - G*256 ;
> brushDraw.Color = Color.FromArgb(R, G, B);
> g.FillRectangle(brushDraw, pt.X, pt.Y, iPenWidth, iPenWidth);
> }
>
> If I know the bounding box, in world coordiantes, its quite easy
to
> do the conversion to screen coordinates, but I can't seem to get
> this info back using the c api. Any help would be greatly
> appreciated, and I can provide more sample code of what I am doing
> if needed.
>
> Thanks in advance,
> Chris
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dkFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/mitab/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/