Skip to content

Commit

Permalink
Clean up comments for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
dtarb committed Mar 13, 2016
1 parent 3631c6b commit 268d8a3
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/streamnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,20 @@ void createStreamNetShapefile(char *streamnetsrc,char *streamnetlyr,OGRSpatialRe
int reachshape(long *cnet,float *lengthd, float *elev, float *area, double *pointx, double *pointy, long np,tiffIO &obj)
{
// Function to write stream network shapefile

int nVertices;
if (np < 2) {//singleton - will be duplicated
nVertices = 2;
}
else {
nVertices = np;
}

double *mypointx = new double[nVertices];
double *mypointy = new double[nVertices];

double x,y,length,glength,x1,y1,xlast,ylast,usarea,dsarea,dslast,dl,drop,slope;
int istart,iend,j;

istart=cnet[1]; // start coord for first link
iend=cnet[2];// end coord for first link


x1=pointx[0];
y1=pointy[0];
length=0.;
Expand All @@ -249,8 +244,6 @@ int reachshape(long *cnet,float *lengthd, float *elev, float *area, double *poin
dslast=usarea;
dsarea=usarea;
long prt = 0;
//const char *pszDriverName = "ESRI Shapefile";


for(j=0; j<np; j++) // loop over points
{
Expand Down Expand Up @@ -298,7 +291,6 @@ int reachshape(long *cnet,float *lengthd, float *elev, float *area, double *poin
glength=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
}


// ensure at least two points (assuming have at least 1) by repeating singleton
if (np < 2) {
mypointx[1] = mypointx[0];
Expand All @@ -312,9 +304,6 @@ int reachshape(long *cnet,float *lengthd, float *elev, float *area, double *poin
// mypointy, // Y values
// NULL); // Z values




hFDefn1 = OGR_L_GetLayerDefn( hLayer1 );
hFeature1 = OGR_F_Create( hFDefn1 );
OGR_F_SetFieldInteger( hFeature1, 0, (int)cnet[0]); // set field value
Expand All @@ -337,19 +326,15 @@ int reachshape(long *cnet,float *lengthd, float *elev, float *area, double *poin

//creating geometry using OGR

//geometry = OGR_G_CreateGeometry( wkbMultiLineString );// want Linestring
line = OGR_G_CreateGeometry( wkbLineString );
for(j=0; j<np; j++) {
OGR_G_AddPoint(line, mypointx[j], mypointy[j], 0);
//OGR_G_AddPoint(line, mypointx[j+1], mypointy[j+1], 0); // it repates the coordinate and increase the file size
OGR_G_AddPoint(line, mypointx[j], mypointy[j], 0);
}
//OGR_G_AddGeometryDirectly(line, line); // don't need
OGR_F_SetGeometryDirectly(hFeature1,line); // set geometry to feature
OGR_F_SetGeometryDirectly(hFeature1,line); // set geometry to feature
OGR_L_CreateFeature( hLayer1, hFeature1 ); //adding feature

delete[] mypointx;
delete[] mypointy;


return 0;
}
Expand Down

0 comments on commit 268d8a3

Please sign in to comment.