I am wanting to read each record of a streets centerline dbf file and for each record get its corresponding Lat/Long.
Are there any MapSuite API's that would help me in this endeavor?
Thanks,
Dennis
I am wanting to read each record of a streets centerline dbf file and for each record get its corresponding Lat/Long.
Are there any MapSuite API's that would help me in this endeavor?
Thanks,
Dennis
Dennis,
You are not giving us a lot of information on your shapefile so let me assume that you have a line based shapefile representing streets. You want to get the Lat/Long of the mid point of each street. We have the API for doing that and basically you would have to follow those steps:
-Loop thru all the street records.
-Get the Geometry of each street (MultilineShape)
-Get the mid point of the MultilineShape
-Do the necessary projection conversion if your shapefile is in a projection other than WGS84 (decimal degrees)
Is that indeed what you are looking for to do?
Thank you.
Val,
Thanks for responding.
Yes, the shapefile is line based representing streets.
I would actually like to retrieve the Lat/Long of the endpoints of each shape.
The API you mention, it is suitable for this? Is it part of the development toolkit? What is the name?
Thanks,
Dennis
Dennis,
Assuming that your street shapefile is already in Decimal Degrees, to get the longitude and latitude of the first and last end point of each line, you could use the code as below. Here, I get a string of the Lat/Long value formated to degrees minutes and seconds but you are free to get it as you want. If your shapefile is in a projection other than decimal degrees, you will have to do some projection conversion in addition.
lineShapefileFeatureLayer.Open();
Collection<Feature> features = lineShapefileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns);
foreach (Feature feature in features)
{
MultilineShape multilineShape = (MultilineShape)feature.GetShape();
string startLong = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(multilineShape.Lines[0].Vertices[0].X);
string startLat = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(multilineShape.Lines[0].Vertices[0].Y);
Vertex endVertex = multilineShape.Lines[multilineShape.Lines.Count -1].Vertices[multilineShape.Lines[multilineShape.Lines.Count -1].Vertices.Count -1];
string endLong = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(endVertex.X);
string endLat = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(endVertex.Y);
}
lineShapefileFeatureLayer.Close();