📄 mitabc_test.c
字号:
y[1] = 48;
mitab_c_set_points( feature, 0, 2, x, y );
mitab_c_set_pen( feature, 1, 2, 255 );
mitab_c_write_feature( dataset, feature );
/* Do not destroy it yet, we'll reuse it for the collection example */
polyline = feature;
/* -------------------------------------------------------------------- */
/* Write text. */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Text );
x[0] = 101;
y[0] = 51;
mitab_c_set_points( feature, 0, 1, x, y );
mitab_c_set_text( feature, "My text" );
mitab_c_set_font( feature, "Arial" );
mitab_c_set_text_display( feature,
45.0, /* angle */
1.0, 7.0, /* Text MBR height and width */
255*65536,/* FG Color */
0, /* BG Color */
-1, -1, -1 );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write region (polygon). */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Region );
x[0] = 101;
y[0] = 51;
x[1] = 100;
y[1] = 51;
x[2] = 100;
y[2] = 50;
x[3] = 101;
y[3] = 50;
x[4] = 101;
y[4] = 51;
mitab_c_set_points( feature, 0, 5, x, y );
x[0] = 100.5;
y[0] = 50.5;
x[1] = 100.5;
y[1] = 50.7;
x[2] = 100.7;
y[2] = 50.7;
x[3] = 100.7;
y[3] = 50.5;
x[4] = 100.5;
y[4] = 50.5;
mitab_c_set_points( feature, 1, 5, x, y );
mitab_c_set_brush( feature, 255, 0, 2, 0 );
mitab_c_set_pen( feature, 1, 2, 0 );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write a second region with two polygon (polygon). */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Region );
x[0] = 101;
y[0] = 41;
x[1] = 100;
y[1] = 41;
x[2] = 100;
y[2] = 40;
x[3] = 101;
y[3] = 40;
x[4] = 101;
y[4] = 41;
mitab_c_set_points( feature, 0, 5, x, y );
x[0] = 100.5;
y[0] = 40.5;
x[1] = 100.5;
y[1] = 40.7;
x[2] = 100.7;
y[2] = 40.7;
x[3] = 100.7;
y[3] = 40.5;
x[4] = 100.5;
y[4] = 40.5;
mitab_c_set_points( feature, 1, 5, x, y );
x[0] = 100.2;
y[0] = 40.2;
x[1] = 100.2;
y[1] = 40.4;
x[2] = 100.4;
y[2] = 40.4;
x[3] = 100.4;
y[3] = 40.2;
x[4] = 100.2;
y[4] = 40.2;
mitab_c_set_points( feature, 2, 5, x, y );
x[0] = 96;
y[0] = 46;
x[1] = 95;
y[1] = 46;
x[2] = 95;
y[2] = 45;
x[3] = 96;
y[3] = 45;
x[4] = 96;
y[4] = 46;
mitab_c_set_points( feature, 0, 5, x, y );
x[0] = 95.5;
y[0] = 45.5;
x[1] = 95.5;
y[1] = 45.7;
x[2] = 95.7;
y[2] = 45.7;
x[3] = 95.7;
y[3] = 45.5;
x[4] = 95.5;
y[4] = 45.5;
mitab_c_set_points( feature, 4, 5, x, y );
mitab_c_set_brush( feature, 255, 0, 2, 0 );
mitab_c_set_pen( feature, 1, 2, 65535 );
mitab_c_write_feature( dataset, feature );
/* Do not destroy it yet, we'll reuse it for the collection example */
region = feature;
/* -------------------------------------------------------------------- */
/* Write multiple polyline (3 parts). */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Polyline );
x[0] = 111;
y[0] = 57;
x[1] = 110;
y[1] = 57;
x[2] = 110;
y[2] = 56;
mitab_c_set_points( feature, 0, 3, x, y );
x[0] = 108;
y[0] = 56;
x[1] = 109;
y[1] = 57;
mitab_c_set_points( feature, 1, 2, x, y );
x[0] = 105;
y[0] = 55;
x[1] = 105;
y[1] = 57;
x[2] = 107;
y[2] = 57;
x[3] = 107;
y[3] = 55;
mitab_c_set_points( feature, 2, 4, x, y );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write an arc */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Arc );
mitab_c_set_arc( feature, 70, 75, 10, 5, 45, 270);
mitab_c_set_field( feature, 0, "123" );
mitab_c_set_field( feature, 1, "456" );
mitab_c_set_field( feature, 2, "12345678901234567890" );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write an ellipse */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Ellipse );
mitab_c_set_arc( feature, 70, 75, 10, 5, 0, 0);
mitab_c_set_field( feature, 0, "1" );
mitab_c_set_field( feature, 1, "2" );
mitab_c_set_field( feature, 2, "3" );
mitab_c_set_brush( feature, 255, 0, 2, 0 );
mitab_c_set_pen( feature, 1, 2, 65535 );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write rectangle. */
/* The MBR of the array of points will be used for the */
/* rectangle corners. */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Rectangle );
x[0] = 91;
y[0] = 61;
x[1] = 90;
y[1] = 61;
x[2] = 90;
y[2] = 60;
x[3] = 91;
y[3] = 60;
x[4] = 91;
y[4] = 61;
mitab_c_set_points( feature, 0, 5, x, y );
mitab_c_set_brush( feature, 255, 0, 2, 0 );
mitab_c_set_pen( feature, 1, 2, 65535 );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Write a collection */
/* reusing the region, polyline and multipoint objects created */
/* above. */
/* -------------------------------------------------------------------- */
feature = mitab_c_create_feature( dataset, TABFC_Collection );
mitab_c_set_field( feature, 0, "1" );
mitab_c_set_field( feature, 1, "2" );
mitab_c_set_field( feature, 2, "Collection" );
/* Set the region and polyline parts.
* Using make_copy=FALSE means that the region/polyline objects will
* be owned by the collection so we don't need to destroy them
*/
mitab_c_set_collection_region( feature, region, 0);
mitab_c_set_collection_polyline( feature, polyline, 0 );
/* Set the multipoint part.
* This time using make_copy=TRUE which means that we remain owner of the
* multipoint and need to destroy it ourselves.
*/
mitab_c_set_collection_multipoint( feature, multipoint, 1 );
mitab_c_destroy_feature( multipoint );
mitab_c_write_feature( dataset, feature );
mitab_c_destroy_feature( feature );
/* -------------------------------------------------------------------- */
/* Cleanup */
/* -------------------------------------------------------------------- */
mitab_c_close( dataset );
if( mitab_c_getlasterrormsg() != NULL
&& strlen(mitab_c_getlasterrormsg()) > 0 )
fprintf( stderr, "Last Error: %s\n", mitab_c_getlasterrormsg() );
}
/************************************************************************/
/* main() */
/************************************************************************/
int main( int nArgc, char ** papszArgv )
{
if( nArgc < 2 )
{
printf( "Usage: mitabc_test src_filename [dst_filename]\n" );
printf( " or mitabc_test -w[mif/tab] dst_filename\n" );
exit( 1 );
}
if( nArgc == 2 )
ReportFile( papszArgv[1] );
else if( strcmp(papszArgv[1],"-wtab") == 0 )
WriteFile( papszArgv[2], "tab" );
else if( strcmp(papszArgv[1],"-wmif") == 0 )
WriteFile( papszArgv[2], "mif" );
else
CopyFile( papszArgv[1], papszArgv[2] );
exit( 0 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -