ThinkGeo.com    |     Documentation    |     Premium Support

Current Extent Issue Using Projection

While setting current extent i’m seeing below error

"The shape you provided does not pass our simple validation.The shape you provided does not pass our simple validation."

Below is the code which I have used to set current extent

Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

            proj4.Open();
            RectangleShape rectangleShape = proj4.ConvertToExternalProjection(new RectangleShape(Convert.ToDouble(country.strExtentMinX), Convert.ToDouble(country.strExtentMaxY), Convert.ToDouble(country.strExtentMaxX), Convert.ToDouble(country.strExtentMinY)));
            proj4.Close();
            map.CurrentExtent = rectangleShape;

and later on i’m setting this projection on ShapeFileFeaureLayer
interestingly it is working on another shape file but not on this one. can you please guide me what i’m doing wrong here.

Regards,

Hey @Malik_Abeer,

Your code looks fine to me. My biggest concern would be the actual data values coming from country.strExtent*. I would guess that the data has the wrong value for min/max X/Y which would cause the RectangleShape to be malformed, causing the Validation error. Especially if this works on a different shapefile.
Take a look at the data and make sure that minX < maxX and minY < maxY. If there is still an issue, can you post the values here so that we can take a look?

Thanks,
Kyle

I’m extracting those values using get extent method of the api and later on when needed im using these values to set extent. The values are

MinX: 6230109.4498768
MaxY: 2756101.7781443
MaxX: 9285136.9550254
MinY: 4468286.9291483

Regards,

jus to explain how it is working on different shape file, the extent values are different and the shape file for that country is different as well but that is working but not on this country shape file.

Hey @Malik_Abeer,

From looking at those values, your MaxY and MinY appear to be in the opposite position. The minimum value of Y (4468286.9291483) is greater than the maximum value of Y (2756101.7781443). This will cause the RectangleShape to be invalid.

In your shapefile’s data, swap the values for strExtentMinY and strExtentMaxY and then you should no longer get that error.

Thanks,
Kyle

by swapping the values the code got executed but the map didn’t redraw to that extent. how to redraw map to latest extent which I have set. i’m calling redrawLayer method on the client side on that overlay which has this new feature layer, it is just drawing that shapefile but not change the extent.

Hi @Malik_Abeer,

I was thinking you are using the MvcEdition, if that’s true, here are all “Client APIs” http://download.thinkgeo.com/docs/MVC/ClientAPI/Default.htm.

To make the map zoom to the specific extent, " zoomToExtent" function of the map control should be called. “redrawLayer” can be only used to reload the data of a specific layer and then redraw according to the map view extent.

Here are the online samples of MvcEdition https://samples.thinkgeo.com/MvcEdition/HowDoISamples/ListPage/ListPageView/?categoryId=AllSamples, please check it out. The source code are at https://github.com/ThinkGeo/HowDoISample-ForMvc

Thanks,
Johnny