本文整理汇总了C++中Vect_reset_line函数的典型用法代码示例。如果您正苦于以下问题:C++ Vect_reset_line函数的具体用法?C++ Vect_reset_line怎么用?C++ Vect_reset_line使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vect_reset_line函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: points
/*!
\brief Get area boundary points (native format)
Used by Vect_build_line_area() and Vect_get_area_points().
\param Map pointer to Map_info struct
\param lines array of boundary lines
\param n_lines number of lines in array
\param[out] APoints pointer to output line_pnts struct
\return number of points
\return -1 on error
*/
int Vect__get_area_points_nat(const struct Map_info *Map, const plus_t *lines, int n_lines,
struct line_pnts *BPoints)
{
int i, line, aline, dir;
static struct line_pnts *Points;
if (!Points)
Points = Vect_new_line_struct();
Vect_reset_line(BPoints);
for (i = 0; i < n_lines; i++) {
line = lines[i];
aline = abs(line);
G_debug(5, " append line(%d) = %d", i, line);
if (0 > Vect_read_line(Map, Points, NULL, aline))
return -1;
dir = line > 0 ? GV_FORWARD : GV_BACKWARD;
Vect_append_points(BPoints, Points, dir);
BPoints->n_points--; /* skip last point, avoids duplicates */
}
BPoints->n_points++; /* close polygon */
return BPoints->n_points;
}
示例2: points
/*!
\brief Get area boundary points (PostGIS Topology)
Used by Vect_build_line_area() and Vect_get_area_points().
\param Map pointer to Map_info struct
\param lines array of boundary lines
\param n_lines number of lines in array
\param[out] APoints pointer to output line_pnts struct
\return number of points
\return -1 on error
*/
int Vect__get_area_points_pg(const struct Map_info *Map, const plus_t *lines, int n_lines,
struct line_pnts *APoints)
{
int i, direction;
struct Format_info_pg *pg_info;
PGresult *res;
pg_info = (struct Format_info_pg *)&(Map->fInfo.pg);
Vect_reset_line(APoints);
res = build_stmt(&(Map->plus), pg_info, lines, n_lines);
if (!res)
return -1;
for (i = 0; i < n_lines; i++) {
Vect__cache_feature_pg(PQgetvalue(res, i, 0), FALSE, FALSE,
&(pg_info->cache), NULL); /* do caching in readable way */
direction = lines[i] > 0 ? GV_FORWARD : GV_BACKWARD;
Vect_append_points(APoints, pg_info->cache.lines[0], direction);
APoints->n_points--; /* skip last point, avoids duplicates */
}
APoints->n_points++; /* close polygon */
PQclear(res);
return APoints->n_points;
}
示例3: Vect_get_isle_points
/*!
\brief Returns polygon array of points for given isle
\param Map pointer to Map_info structure
\param isle island id
\param[out] BPoints points array
\return number of points
\return -1 on error
*/
int Vect_get_isle_points(const struct Map_info *Map,
int isle, struct line_pnts *BPoints)
{
const struct Plus_head *Plus;
struct P_isle *Isle;
G_debug(3, "Vect_get_isle_points(): isle = %d", isle);
Vect_reset_line(BPoints);
Plus = &(Map->plus);
Isle = Plus->Isle[isle];
if (Isle == NULL) { /* dead isle */
G_warning(_("Attempt to read points of nonexistent isle"));
return -1; /* error, because we should not read dead isles */
}
G_debug(3, " n_lines = %d", Isle->n_lines);
if (Map->format == GV_FORMAT_POSTGIS &&
Map->fInfo.pg.toposchema_name &&
Map->fInfo.pg.cache.ctype != CACHE_MAP) {
#ifdef HAVE_POSTGRES
/* PostGIS Topology */
return Vect__get_area_points_pg(Map, Isle->lines, Isle->n_lines, BPoints);
#else
G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
#endif
}
/* native format */
return Vect__get_area_points_nat(Map, Isle->lines, Isle->n_lines, BPoints);
}
示例4: write_point
void write_point(struct Map_info *Out, double x, double y, double z,
int line_cat, double along, int table)
{
char buf[2000];
G_debug(3, "write_point()");
Vect_reset_line(PPoints);
Vect_reset_cats(PCats);
/* Write point */
Vect_append_point(PPoints, x, y, z);
Vect_cat_set(PCats, 1, line_cat);
Vect_cat_set(PCats, 2, point_cat);
Vect_write_line(Out, GV_POINT, PPoints, PCats);
/* Attributes */
if (!table) {
db_zero_string(&stmt);
sprintf(buf, "insert into %s values ( %d, %d, %.15g )", Fi->table,
point_cat, line_cat, along);
db_append_string(&stmt, buf);
if (db_execute_immediate(driver, &stmt) != DB_OK) {
G_warning(_("Unable to insert new record: '%s'"),
db_get_string(&stmt));
}
}
point_cat++;
}
示例5: writePolyline
void writePolyline( struct Map_info* map, int type, QgsPolyline polyline, struct line_cats *cats )
{
Vect_reset_line( line );
foreach ( QgsPoint point, polyline )
{
Vect_append_point( line, point.x(), point.y(), 0 );
}
示例6: ring2pts
static int ring2pts(const GEOSGeometry *geom, struct line_pnts *Points)
{
int i, ncoords;
double x, y, z;
const GEOSCoordSequence *seq = NULL;
G_debug(3, "ring2pts()");
Vect_reset_line(Points);
if (!geom) {
G_warning(_("Invalid GEOS geometry!"));
return 0;
}
z = 0.0;
ncoords = GEOSGetNumCoordinates(geom);
if (!ncoords) {
G_warning(_("No coordinates in GEOS geometry (can be ok for negative distance)!"));
return 0;
}
seq = GEOSGeom_getCoordSeq(geom);
for (i = 0; i < ncoords; i++) {
GEOSCoordSeq_getX(seq, i, &x);
GEOSCoordSeq_getY(seq, i, &y);
if (x != x || x > DBL_MAX || x < -DBL_MAX)
G_fatal_error(_("Invalid x coordinate %f"), x);
if (y != y || y > DBL_MAX || y < -DBL_MAX)
G_fatal_error(_("Invalid y coordinate %f"), y);
Vect_append_point(Points, x, y, z);
}
return 1;
}
示例7: G_site_put
/* Writes a site to file open on fptr. */
int G_site_put(struct Map_info *Map, const Site * s)
{
static struct line_pnts *Points = NULL;
static struct line_cats *Cats = NULL;
if (Points == NULL)
Points = Vect_new_line_struct();
if (Cats == NULL)
Cats = Vect_new_cats_struct();
Vect_reset_line(Points);
Vect_reset_cats(Cats);
/* no 3D support so far: s->dim[0] */
Vect_append_point(Points, s->east, s->north, 0.0);
G_debug(4, "cattype = %d", s->cattype);
if (s->cattype == FCELL_TYPE || s->cattype == DCELL_TYPE)
G_fatal_error(_("Category must be integer"));
if (s->cattype == CELL_TYPE)
Vect_cat_set(Cats, 1, s->ccat);
Vect_write_line(Map, GV_POINT, Points, Cats);
return 0;
}
示例8: Vect_reset_line
void QgsGrassEditAddVertex::mouseMove( QgsPoint & newPoint )
{
if ( e->mSelectedLine > 0 )
{
Vect_reset_line( e->mPoints );
if ( e->mAddVertexEnd )
{
Vect_append_point( e->mPoints, e->mEditPoints->x[e->mSelectedPart],
e->mEditPoints->y[e->mSelectedPart], 0.0 );
Vect_append_point( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
}
else
{
Vect_append_point( e->mPoints, e->mEditPoints->x[e->mSelectedPart-1],
e->mEditPoints->y[e->mSelectedPart-1], 0.0 );
Vect_append_point( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
Vect_append_point( e->mPoints, e->mEditPoints->x[e->mSelectedPart],
e->mEditPoints->y[e->mSelectedPart], 0.0 );
}
for ( int i = 0; i < e->mPoints->n_points; i++ )
{
QgsDebugMsg( QString( "%1 %2" ).arg( e->mPoints->x[i] ).arg( e->mPoints->y[i] ) );
}
e->displayDynamic( e->mPoints );
}
}
示例9: writePolyline
void writePolyline( struct Map_info* map, int type, const QgsPolyline& polyline, struct line_cats *cats )
{
Vect_reset_line( line );
Q_FOREACH ( const QgsPoint& point, polyline )
{
Vect_append_point( line, point.x(), point.y(), 0 );
}
示例10: pie
int
pie(double cx, double cy, int size, double *val, int ncols, COLOR * ocolor,
COLOR * colors)
{
int i, j, n;
double a, end_ang, ang, tot_sum, sum, step, r;
double x, y;
struct line_pnts *Points;
G_debug(4, "pie(): cx = %f cy = %f", cx, cy);
Points = Vect_new_line_struct();
/* Calc sum */
tot_sum = 0;
for (i = 0; i < ncols; i++)
tot_sum += val[i];
step = PI / 180;
r = (D_d_to_u_col(2) - D_d_to_u_col(1)) * size / 2; /* do it better */
/* Draw polygon for each value */
sum = 0;
ang = 0;
for (i = 0; i < ncols; i++) {
sum += val[i];
end_ang = 2 * PI * sum / tot_sum;
Vect_reset_line(Points);
if (val[0] != tot_sum) /* all in one slice, don't draw line to center */
Vect_append_point(Points, cx, cy, 0);
n = (int)ceil((end_ang - ang) / step);
for (j = 0, a = ang; j <= n; j++, a += step) {
if (a > end_ang)
a = end_ang;
x = cx + r * cos(a);
y = cy + r * sin(a);
Vect_append_point(Points, x, y, 0);
}
ang = end_ang;
if (val[0] != tot_sum)
Vect_append_point(Points, cx, cy, 0);
if (!colors[i].none) {
D_RGB_color(colors[i].r, colors[i].g, colors[i].b);
D_polygon_abs(Points->x, Points->y, Points->n_points);
}
D_RGB_color(ocolor->r, ocolor->g, ocolor->b);
D_polyline_abs(Points->x, Points->y, Points->n_points);
}
Vect_destroy_line_struct(Points);
return 0;
}
示例11: offset
/*!
\brief Read feature from OGR layer at given offset (level 1)
This function implements random access on level 1.
\param Map pointer to Map_info structure
\param[out] line_p container used to store line points within
\param[out] line_c container used to store line categories within
\param offset given offset
\return line type
\return 0 dead line
\return -2 no more features
\return -1 out of memory
*/
int V1_read_line_ogr(struct Map_info *Map,
struct line_pnts *line_p, struct line_cats *line_c, off_t offset)
{
long FID;
int type;
OGRGeometryH hGeom;
G_debug(4, "V1_read_line_ogr() offset = %lu offset_num = %lu",
(long) offset, (long) Map->fInfo.ogr.offset_num);
if (offset >= Map->fInfo.ogr.offset_num)
return -2;
if (line_p != NULL)
Vect_reset_line(line_p);
if (line_c != NULL)
Vect_reset_cats(line_c);
FID = Map->fInfo.ogr.offset[offset];
G_debug(4, " FID = %ld", FID);
/* coordinates */
if (line_p != NULL) {
/* Read feature to cache if necessary */
if (Map->fInfo.ogr.feature_cache_id != FID) {
G_debug(4, "Read feature (FID = %ld) to cache", FID);
if (Map->fInfo.ogr.feature_cache) {
OGR_F_Destroy(Map->fInfo.ogr.feature_cache);
}
Map->fInfo.ogr.feature_cache =
OGR_L_GetFeature(Map->fInfo.ogr.layer, FID);
if (Map->fInfo.ogr.feature_cache == NULL) {
G_fatal_error(_("Unable to get feature geometry, FID %ld"),
FID);
}
Map->fInfo.ogr.feature_cache_id = FID;
}
hGeom = OGR_F_GetGeometryRef(Map->fInfo.ogr.feature_cache);
if (hGeom == NULL) {
G_fatal_error(_("Unable to get feature geometry, FID %ld"),
FID);
}
type = read_line(Map, hGeom, offset + 1, line_p);
}
else {
type = get_line_type(Map, FID);
}
/* category */
if (line_c != NULL) {
Vect_cat_set(line_c, 1, (int) FID);
}
return type;
}
示例12: structure
/*!
\brief Writes point
Writes GV_POINT to Out at the position of the node in <em>In</em>.
\param In pointer to Map_info structure (input vector map)
\param[in,out] Out pointer to Map_info structure (output vector map)
\param node node id
\param Cats pointer to line_cats structures
*/
void NetA_add_point_on_node(struct Map_info *In, struct Map_info *Out,
int node, struct line_cats *Cats)
{
static struct line_pnts *Points;
double x, y, z;
Points = Vect_new_line_struct();
Vect_get_node_coor(In, node, &x, &y, &z);
Vect_reset_line(Points);
Vect_append_point(Points, x, y, z);
Vect_write_line(Out, GV_POINT, Points, Cats);
Vect_destroy_line_struct(Points);
}
示例13: layer
/*!
\brief Reads feature from OGR layer (topology level)
This function implements random access on level 2.
\param Map pointer to Map_info structure
\param[out] line_p container used to store line points within
\param[out] line_c container used to store line categories within
\param line feature id
\return feature type
\return -2 no more features
\return -1 out of memory
*/
int V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
struct line_cats *line_c, int line)
{
struct P_line *Line;
G_debug(4, "V2_read_line_ogr() line = %d", line);
Line = Map->plus.Line[line];
if (Line == NULL)
G_fatal_error(_("Attempt to read dead feature %d"), line);
if (Line->type == GV_CENTROID) {
G_debug(4, "Centroid");
if (line_p != NULL) {
int i, found;
struct bound_box box;
struct boxlist list;
struct P_topo_c *topo = (struct P_topo_c *)Line->topo;
/* get area bbox */
Vect_get_area_box(Map, topo->area, &box);
/* search in spatial index for centroid with area bbox */
dig_init_boxlist(&list, 1);
Vect_select_lines_by_box(Map, &box, Line->type, &list);
found = 0;
for (i = 0; i < list.n_values; i++) {
if (list.id[i] == line) {
found = i;
break;
}
}
Vect_reset_line(line_p);
Vect_append_point(line_p, list.box[found].E, list.box[found].N, 0.0);
}
if (line_c != NULL) {
/* cat = FID and offset = FID for centroid */
Vect_reset_cats(line_c);
Vect_cat_set(line_c, 1, (int) Line->offset);
}
return GV_CENTROID;
}
return V1_read_line_ogr(Map, line_p, line_c, Line->offset);
}
示例14: Vect_line_segment
/*!
\brief Create line segment.
Creates segment of InPoints from start to end measured along the
line and write it to OutPoints.
If the distance is greater than line length or negative, error is
returned.
\param InPoints input line
\param start segment number
\param end segment number
\param OutPoints output line
\return 1 success
\return 0 error when start > length or end < 0 or start < 0 or end > length
*/
int Vect_line_segment(const struct line_pnts *InPoints, double start, double end,
struct line_pnts *OutPoints)
{
int i, seg1, seg2;
double length, tmp;
double x1, y1, z1, x2, y2, z2;
G_debug(3, "Vect_line_segment(): start = %f, end = %f, n_points = %d",
start, end, InPoints->n_points);
Vect_reset_line(OutPoints);
if (start > end) {
tmp = start;
start = end;
end = tmp;
}
/* Check start/end */
if (end < 0)
return 0;
length = Vect_line_length(InPoints);
if (start > length)
return 0;
/* Find coordinates and segments of start/end */
seg1 = Vect_point_on_line(InPoints, start, &x1, &y1, &z1, NULL, NULL);
seg2 = Vect_point_on_line(InPoints, end, &x2, &y2, &z2, NULL, NULL);
G_debug(3, " -> seg1 = %d seg2 = %d", seg1, seg2);
if (seg1 == 0 || seg2 == 0) {
G_warning(_("Segment outside line, no segment created"));
return 0;
}
Vect_append_point(OutPoints, x1, y1, z1);
for (i = seg1; i < seg2; i++) {
Vect_append_point(OutPoints, InPoints->x[i], InPoints->y[i],
InPoints->z[i]);
};
Vect_append_point(OutPoints, x2, y2, z2);
Vect_line_prune(OutPoints);
return 1;
}
示例15: QgsDebugMsg
void QgsGrassEditNewLine::activate()
{
QgsDebugMsg( "entered." );
// Display dynamic segment
if ( e->mEditPoints->n_points > 0 )
{
Vect_reset_line( e->mPoints );
Vect_append_points( e->mPoints, e->mEditPoints, GV_FORWARD );
QgsPoint point = toMapCoordinates( e->mCanvas->mouseLastXY() );
Vect_append_point( e->mPoints, point.x(), point.y(), 0.0 );
e->displayDynamic( e->mPoints );
}
QgsGrassEditTool::activate(); // call default bahivour
}