How to symbolize a point shape file

I would like to set a different point type or style based on an attribute in a point shape file? How do I get access to all the attribute fields in a shape file?
Thanks.
Thanks.
Comments
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
for (Int32 j = 0; j < Convert.ToInt32(theLayerInfo.mNumPoints); j++)
{
IntPtr theInfoPtr = GlobalMapperDLL.GM_GetPointFeature(theLayerHandle, (uint)j);
myPointStyle = (
GM_PointStyle_t)Marshal.PtrToStructure(theInfoPtr, myPointStyle.GetType());
//myPointStyle.mSymbolName = "SQUARE_CUSTOM_2_255_0_0";
myPointStyle.mSymbolName =
PointFeatureClass_t16.PFC_HOSPITAL.ToString();
GlobalMapperDLL.GM_SetPointFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(j), ref myPointStyle);
}
// Sets the drawing style to use for a given point feature
[
DllImport(DLLFileName, EntryPoint = "GM_SetPointFeatureDrawStyle")]
public static extern GM_Error_t32 GM_SetPointFeatureDrawStyle
(
//GM_LayerHandle_t32 aLayer, // Layer the point is in
//UInt32 aPointIndex, // Index of point in layer
//ref IntPtr aPointStyle // (const GM_PointStyle_t*) New style to use for point, pass IntPtr.Zero to restore default type-based stuff
IntPtr aLayer, // Layer the point is in
UInt32 aPointIndex, // Index of point in layer
ref GM_PointStyle_t aPointStyle // New style to use for point
);
mPointStyle.mSymbolName = "Hospital";
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
private void create_point_marker(double lat, double lon) {
GM_PointFeature_t thePoint = new GM_PointFeature_t();
thePoint.mFeatureInfo.mName = "Locatie contract";
thePoint.mFeatureInfo.mDesc = null;
// thePoint.mFeatureInfo.mClass = "PFC_TOWER";
thePoint.mPointStyle.mSymbolName = "Fish";
thePoint.mPointStyle.mDrawLabel = 1;
thePoint.mPos.mX=lon;
thePoint.mPos.mY = lat;
// Add the point to the custom layer
LastGMError = GlobalMapperDLL.GM_AddPointToVectorLayer(theLayerHandle, ref thePoint, 0);
GlobalMapperDLL.GM_SetLayerEnabled(theLayerHandle, 1);
DrawLayersToBitmap();
}
/////////////////
But there's no point with a fish symbol. THen I append more lines of code to make an iteration to find if there is a point. But there's no point. (TheLayerInfo.mNumPoints=0)
////
IntPtr theInfoPtr;
for (Int32 j = 0; j < Convert.ToInt32(theLayerInfo.mNumPoints); j++)
{
theInfoPtr = GlobalMapperDLL.GM_GetPointFeature(theLayerHandle, (uint)j);
GM_PointStyle_t myPointStyle = new GM_PointStyle_t();
//Check it is inside the grid bounds
myPointStyle = (GM_PointStyle_t)Marshal.PtrToStructure(theInfoPtr, myPointStyle.GetType());
myPointStyle.mSymbolName = "Hospital";
GlobalMapperDLL.GM_SetPointFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(j), ref myPointStyle);
}
///
Please help me!
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
unsafe private void create_area(GM_Point_t[] theAreaPoints)
{
GlobalMapperDLL.GM_Error_t32 theErrCode = 0;
// Test creating a new area and adding it to the layer
if (theLayerInfo.mNumAreas > 0)
{
// Setup a building northeast of the center point that is 20 meters high
double theCenterX = (theLayerInfo.mGlobalRect.mMaxX + theLayerInfo.mGlobalRect.mMinX) / 2.0;
double theCenterY = (theLayerInfo.mGlobalRect.mMaxY + theLayerInfo.mGlobalRect.mMinY) / 2.0;
double theAreaWidth =
(theLayerInfo.mGlobalRect.mMaxX - theLayerInfo.mGlobalRect.mMinX) / 32.0;
double theAreaHeight =
(theLayerInfo.mGlobalRect.mMaxY - theLayerInfo.mGlobalRect.mMinY) / 32.0;
double theAreaCenterX = theCenterX + theAreaWidth;
double theAreaCenterY = theCenterY + theAreaHeight;
// Fix location of things we need pointers for
string theAttrName = "ELEVATION";
string theAttrVal = "20 m";
fixed (char* theAttrNamePtr = theAttrName, theAttrValPtr = theAttrVal)
{
// Setup an attribute value for the elevation
GM_AttrValueCharPtr_t[] theAttrValList = new GM_AttrValueCharPtr_t[1];
theAttrValList[0].mName = theAttrNamePtr;
theAttrValList[0].mVal = theAttrValPtr;
fixed (GM_AttrValueCharPtr_t* theAttrValListPtr = &theAttrValList[0])
{
fixed (GM_Point_t* thePointList = &theAreaPoints[0])
{
// Setup the area structure
GM_AreaFeature_t theBuilding = new GM_AreaFeature_t();
theBuilding.mFeatureInfo.mName = "Test Building";
theBuilding.mFeatureInfo.mDesc = "Building";
theBuilding.mFeatureInfo.mClass = (ushort)AreaFeatureClass_t16.AFC_UNKNOWN;
theBuilding.mFeatureInfo.mAttrList = (IntPtr)theAttrValListPtr;
theBuilding.mFeatureInfo.mNumAttrs = 1;
theBuilding.mPointList = (IntPtr)thePointList;
theBuilding.mNumPoints = (uint)theAreaPoints.Length;
// Setup the color to be solid blue
theBuilding.mAreaStyle.mBrushStyle = GM_BrushStyle_t16.GM_BRUSH_SOLID;
theBuilding.mAreaStyle.mBrushColor = 0x00200000;
theBuilding.mAreaStyle.mBrushColor = (uint)128UL << 24;
// Add the building polygon to the custom layer
theErrCode = GlobalMapperDLL.GM_AddAreaToVectorLayer
(
theLayerHandle,
ref theBuilding,
GlobalMapperDLL.GM_AddFeatureFlags_t8.GM_AddFeature_UseDefaultStyle
);
}
}
}
}
}
theErrCode = GlobalMapperDLL.GM_AddAreaToVectorLayer( theLayerHandle, ref theBuilding, 0 );
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
However, do you have a license for the SDK active and set with GM_SetLicenseKey (if so GM_IsRegistered will return TRUE)? If not, the GM_GetAreaFeature (and same for line and point access) function will return a NULL pointer for anything after index 5 (GM_MAX_NON_REGISTERED_VECTOR_IDX in the GlobalMapperInterface.h header file) as you have to have a license to get at any feature. The first few features are allowed access without a license just for testing before deciding to purchase a license. So it's a somewhat common problem to encounter this error if you don't have a license or it hasn't been activated properly in the code.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation