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; } } }
/// <summary> /// An SQL where clause for an ODM sites table /// </summary> /// <param name="geom"></param> /// <param name="tableName"></param> /// <returns></returns> public static String GeomToSqlWhere(basicGeometry geom, string tableName) { if (geom.GetType().Equals(typeof(box))) { box queryBox = (box)geom; string sqlClause = string.Format(boxSqlFormat, tableName, queryBox.South, queryBox.North, queryBox.West, queryBox.East); return(sqlClause); } else { throw new WaterOneFlowException("Only Box is understood at this time"); } }
public static String GeomToSeriesSqlWhere(basicGeometry geom) { return(GeomToSqlWhere(geom, "Series")); }
public locationParam(String inputParam) { location = inputParam; // cannot be a split using a colon... EPA ID's use a damn colon //. needs to be a parse first separator /* new logic * get Options, if present * Then do the code parsing * */ // get options String[] s = inputParam.Split(optionBlockSep.ToCharArray()); if (s.Length > 1) { for (int i = 1; i < s.Length; i++) { String[] l = s[i].Split(optionSep.ToCharArray()); if (l.Length < 2) { throw new WaterOneFlowException("Location options should be key=value pairs " + inputParam); } else { addOption(l[0], l[1]); } } } String networkSiteCode = s[0]; String[] lp = new String[2]; if (networkSiteCode.Contains(networkSeparator)) { int sepPosition = networkSiteCode.IndexOf(networkSeparator); lp[0] = networkSiteCode.Substring(0, sepPosition).Trim(); lp[1] = networkSiteCode.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; } } }