Ejemplo n.º 1
0
OGRPolygon* OGRMSSQLGeometryParser::ReadPolygon(int iShape)
{
    int iFigure, iPoint, iNextPoint, i;
    int iNextFigure = NextFigureOffset(iShape);
    
    OGRPolygon* poPoly = new OGRPolygon();
    for (iFigure = FigureOffset(iShape); iFigure < iNextFigure; iFigure++)
    {
        OGRLinearRing* poRing = new OGRLinearRing();
        iPoint = PointOffset(iFigure);
        iNextPoint = NextPointOffset(iFigure);
        poRing->setNumPoints(iNextPoint - iPoint);
        i = 0;
        while (iPoint < iNextPoint)
        {
            if ( chProps & SP_HASZVALUES )
                poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) );
            else
                poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint) );

            ++iPoint;
            ++i;
        }
        poPoly->addRingDirectly( poRing );
    }
    return poPoly;
}
Ejemplo n.º 2
0
mapnik::geometry::polygon<double> sqlserver_geometry_parser::ReadPolygon(int iShape)
{
	mapnik::geometry::polygon<double> geom;
    int iNextFigure = NextFigureOffset(iShape);
    
    for (int iFigure = FigureOffset(iShape); iFigure < iNextFigure; iFigure++) {
		mapnik::geometry::linear_ring<double> ring;
		int iPoint = PointOffset(iFigure);
        int iNextPoint = NextPointOffset(iFigure);
        while (iPoint < iNextPoint) {
            if (colType == Geography) {
                ring.emplace_back(ReadY(iPoint), ReadX(iPoint));
            } else {
                ring.emplace_back(ReadX(iPoint), ReadY(iPoint));
            }

            ++iPoint;
        }
		if (iFigure == 0) {
			geom.set_exterior_ring(std::move(ring));
		} else {
			geom.add_hole(std::move(ring));
		}
	}
    return geom;
}
Ejemplo n.º 3
0
void QgsMssqlGeometryParser::ReadPolygon( int iShape )
{
  int iFigure, iPoint, iNextPoint, iCount, i;
  int iNextFigure = NextFigureOffset( iShape );
  iCount = iNextFigure - FigureOffset( iShape );
  if ( iCount <= 0 )
    return;
  // copy byte order
  CopyBytes( &chByteOrder, 1 );
  // copy type
  int wkbType;
  if ( chProps & SP_HASZVALUES )
    wkbType = QGis::WKBPolygon25D;
  else
    wkbType = QGis::WKBPolygon;
  CopyBytes( &wkbType, 4 );
  // copy ring count
  CopyBytes( &iCount, 4 );
  // copy rings
  for ( iFigure = FigureOffset( iShape ); iFigure < iNextFigure; iFigure++ )
  {
    iPoint = PointOffset( iFigure );
    iNextPoint = NextPointOffset( iFigure );
    iCount = iNextPoint - iPoint;
    if ( iCount <= 0 )
      continue;
    // copy point count
    CopyBytes( &iCount, 4 );
    // copy coordinates
    i = 0;
    while ( iPoint < iNextPoint )
    {
      CopyCoordinates( iPoint );
      ++iPoint;
      ++i;
    }
  }
}