public void Test_Constructor() { ProjectionParameter[] paramList = new ProjectionParameter[2]; paramList[0].Name="test"; paramList[0].Value=2.2; paramList[1].Name="test2"; paramList[1].Value=2.3; Projection projection = new Projection("mercator",paramList,"class","remarks","authority","authoritycode"); Assertion.AssertEquals("test 1","mercator",projection.Name); Assertion.AssertEquals("test 2","class",projection.ClassName); Assertion.AssertEquals("test 3",2,projection.NumParameters); //Assertion.AssertEquals("test 4a",2.2,projection.get_Parameter(0).Value); //Assertion.AssertEquals("test 4b","test",projection.get_Parameter(0).Name); //Assertion.AssertEquals("test 5a",2.3,projection.get_Parameter(1).Value); //Assertion.AssertEquals("test 5b","test2",projection.get_Parameter(1).Name); Assertion.AssertEquals("test 6","remarks",projection.Remarks); Assertion.AssertEquals("test 7","authority",projection.Authority); Assertion.AssertEquals("Test 8","authoritycode",projection.AuthorityCode); }
private static IProjection ReadProjection(XmlTextReader reader) { if (!(reader.NodeType==XmlNodeType.Element && reader.Name=="CS_Projection")) { throw new ParseException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Expected a IProjection but got a {0} at line {1} col {2}",reader.Name,reader.LineNumber,reader.LinePosition)); } string className=reader.GetAttribute("ClassName"); reader.Read(); string authority="",authorityCode="",abbreviation="",name=""; ReadInfo(reader, ref authority,ref authorityCode, ref abbreviation, ref name); ArrayList list = new ArrayList(); while (reader.NodeType==XmlNodeType.Element && reader.Name=="CS_ProjectionParameter") { ProjectionParameter param = ReadProjectionParameter( reader ); list.Add(param); reader.Read(); } ProjectionParameter[] projectionParams = new ProjectionParameter[list.Count]; projectionParams = (ProjectionParameter[])list.ToArray(typeof(ProjectionParameter)); Projection projection = new Projection(name,projectionParams,className,"",authority,authorityCode); return projection; }
private IProjection CreateProjection(string code, string projectionCode) { string sqlQuery = "SELECT COORD_OP_METHOD_NAME, REVERSE_OP, REMARKS "+ "FROM [Coordinate_Operation Method] "+ "WHERE COORD_OP_METHOD_CODE={0}"; sqlQuery = String.Format(sqlQuery,code); IDataReader reader = Database.ExecuteQuery(_databaseConnection,sqlQuery); if (!reader.Read()) { throw new ArgumentException(String.Format("A coordinate operation with a code of {0} could not be found.",code)); } string name = reader["COORD_OP_METHOD_NAME"].ToString(); string remarks = reader["REMARKS"].ToString(); Database.CheckOneRow(reader,code,"Datum"); ProjectionParameter[] projectionParameters = this.GetProjectionParameterInfo(projectionCode,"ignore"); Projection projection = new Projection(name,projectionParameters,name,remarks,"EPSG",code); return projection; }
private static IProjection ReadProjection(WktStreamTokenizer tokenizer) { //tokenizer.NextToken();// PROJECTION tokenizer.ReadToken("PROJECTION"); tokenizer.ReadToken("[");//[ string projectionName=tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken("]");//] tokenizer.ReadToken(",");//, tokenizer.ReadToken("PARAMETER"); ParameterList paramList = new ParameterList(); while (tokenizer.GetStringValue()=="PARAMETER") { tokenizer.ReadToken("["); string paramName = tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.NextToken(); double paramValue = tokenizer.GetNumericValue(); tokenizer.ReadToken("]"); tokenizer.ReadToken(","); paramList.Add(paramName,paramValue); tokenizer.NextToken(); } ProjectionParameter[] paramArray = new ProjectionParameter[paramList.Count]; int i=0; foreach(string key in paramList.Keys) { ProjectionParameter param= new ProjectionParameter(); param.Name=key; param.Value=(double)paramList[key]; paramArray[i]=param; i++; } string authority=""; string authorityCode=""; IProjection projection = new Projection(projectionName, paramArray,"", "",authority, authorityCode); return projection; }