public locationParam(String inputParam) { location = inputParam; String[] lp = new String[2]; if (inputParam.Contains(networkSeparator)) { int sepPosition = inputParam.IndexOf(networkSeparator); lp[0] = inputParam.Substring(0, sepPosition).Trim(); lp[1] = inputParam.Substring(sepPosition + 1).Trim(); Network = lp[0]; SiteCode = lp[1].Trim(); if (Network.Equals(siteIDNetwork, StringComparison.InvariantCultureIgnoreCase)) { IsId = true; try { int.Parse(SiteCode); } catch (Exception e) { throw new WaterOneFlowException("SITEID must be an integer. '" + location + "'"); } } if (Network.Equals(basicGeometry.geomNetworkID)) { isGeometry = true; if (lp[1].StartsWith(box.geomType, StringComparison.InvariantCultureIgnoreCase)) { Geometry = new box(lp[1]); } else if (lp[1].StartsWith(point.geomType, StringComparison.InvariantCultureIgnoreCase)) { Geometry = new point(lp[1]); } else { // unsupported geometry throw new WaterOneFlowException("Unsupported Geometry :'" + SiteCode + "' " + "Must be BOX or POINT"); } } else { isGeometry = false; } } }
private void parseBox(String bs) { bs = bs.Trim(); if (bs.StartsWith(geomType,StringComparison.InvariantCultureIgnoreCase)) { // remove point, and matching brackets bs = bs.Substring(geomType.Length); if (bs.StartsWith("((")) { bs = bs.Substring(2); } if (bs.EndsWith("))")) { bs = bs.Remove(bs.Length - 2); } if (bs.StartsWith("(")) { bs = bs.Substring(1); } } if (bs.EndsWith(")")) { bs = bs.Remove(bs.Length - 1); } bs = bs.Trim(); String[] xy = bs.Split(XYPairSeparator.ToCharArray()); if (xy.Length == 2) { point ws = new point(xy[0]); this.West = ws.X; this.South = ws.Y; point en = new point(xy[1]); this.North = en.Y; this.East = en.X; } else if (xy.Length == 4) { // not completeltly correct, but why not make four coordinates work this.North = Double.Parse(xy[0]); this.East = Double.Parse(xy[1]); this.West = Double.Parse(xy[2]); this.South = Double.Parse(xy[3]); } }