打印本文 打印本文 关闭窗口 关闭窗口
Oracle空间数据库的读取与写入
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4225  更新时间:2009/4/22 22:06:16  文章录入:mintao  责任编辑:mintao
nates for a type2 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type2 (void)

{
   int interp = get_interpretation ();

   get_ordinates (get_next_starting_offset(global_ending_offset == -1),
                  get_next_ending_offset (0));
}

/*******************************************************************************
**
** Routine:     sc_ops_get_type3
**
** Description: Print the ordinates for a type3 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type3 (void)

{
   int interp = get_interpretation (),
       start  = get_next_starting_offset(global_ending_offset == -1),
       end    = get_next_ending_offset(0);

   if (interp == 3) /* Rectangle, 2 po;ints */
     get_ordinates (start,
                    start + global_num_dimensions * 2 - 1);

   else if (interp == 4) /* Circle, 3 points */
     get_ordinates (start,
                    start + global_num_dimensions * 3 - 1);

   else if (interp == 1 || interp == 2) /* interpretation 1 or 2 */
     get_ordinates (start, end);
}


/*******************************************************************************
**
** Routine:     sc_ops_get_type4
**
** Description: Print the ordinates for a type4 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type4 (void)

{
  int interp = get_interpretation (),
      start,
      end,
      i;

  for (i = 0; i < interp; i++)
  {
     global_elem_index = global_elem_index + 3;
     start  = get_next_starting_offset(-1);
 
     if (i == interp - 1)
       end = get_next_ending_offset(0);
     else
       end = get_next_ending_offset(1);

     get_ordinates (start, end);
  }
}


/*******************************************************************************
**
** Routine:     sc_ops_get_type5
**
** Description: Print the ordinates for a type5 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type5 (void)

{
  int interp = get_interpretation (),
      start,
      end,
      i;

  for (i = 0; i < interp; i++)
  {
     global_elem_index = global_elem_index + 3;
     start  = get_next_starting_offset(-1);
 
     if (i == interp - 1)
       end = get_next_ending_offset(0);
     else
       end = get_next_ending_offset(1);

     get_ordinates (start, end);
  }
}


/*******************************************************************************
**
** Routine:     write_geometries
**
** Description:
**
*******************************************************************************/
void WReadAndWriteGeometry::write_geometries ()
{
 int i;
 int starting_offset = 1;
 int element_type = 2;
 int interpretation = 1;
 OCINumber oci_number;
 OCIBind *bnd1p = NULL, *bnd2p = NULL;
 char query[500];

 for (i = 0; i < 1002; i++)
 {
  checkerr(errhp, OCINumberFromReal(errhp, (dvoid *)&(test_ordinates[i]),
      (uword)sizeof(double),&oci_number));

  checkerr(errhp, OCICollAppend(envhp, errhp,
      (dvoid *) &oci_number,
      (dvoid *)0, (OCIColl *)ordinates));
 }

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&starting_offset,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&element_type,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&interpretation,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 sprintf(query, "INSERT INTO %s (gid, %s) "
     "VALUES (1, %s(4, NULL, NULL, :elem_info, :ordinates))",
     "test_insert", "geometry", SDO_GEOMETRY);

 checkerr(errhp, OCIStmtPrepare(stmthp, errhp,
     (text *)query, (ub4)strlen(query),
     (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT));


 /* bind info_obj varray object */
 checkerr(errhp, OCIBindByName(stmthp, &bnd1p, errhp,
     (text *)":elem_info", (sb4)-1, (dvoid *)0,
     (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0,
     (ub2 *)0, (ub4)0, (ub4 *)0,
     (ub4)OCI_DEFAULT));
 checkerr(errhp, OCIBindObject(bnd1p, errhp, elem_info_tdo,
     (dvoid **)&elem_info, (ub4 *)0,
     (dvoid **)0, (ub4 *)0));
 /* bind coordinate varray object */
 checkerr(errhp, OCIBindByName(stmthp, &bnd2p, errhp,
     (text *)":ordinates", (sb4)-1, (dvoid *)0,
     (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0,
     (ub2 *)0, (ub4)0, (ub4 *)0,
     (ub4)OCI_DEFAULT));
 checkerr(errhp, OCIBindObject(bnd2p, errhp, ordinates_tdo,
     (dvoid **)&ordinates, (ub4 *)0,
     (dvoid **)0, (ub4 *)0));

 checkerr(errhp, OCIStmtExecute(svchp, stmthp, errhp, (ub4)1, (ub4)0,
     (OCISnapshot *)NULL, (OCISnapshot *)NULL,
     (ub4)OCI_DEFAULT));
}

上一页  [1] [2] [3] [4] [5] 

打印本文 打印本文 关闭窗口 关闭窗口