Author Topic: Need developer for a small project in VB.NET $  (Read 2556 times)

0 Members and 1 Guest are viewing this topic.

sigster

  • Newt
  • Posts: 31
Need developer for a small project in VB.NET $
« on: February 01, 2018, 09:19:01 AM »
Send me estimate AND hourly rate via private message

Basic import Autocad MAP 3D

1. Use dotspatial to import
   Polyline/Line

2. Option to select what Layer I want to import to
3. Progressbar when importing

Regards
Sigster

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: Need developer for a small project in VB.NET $
« Reply #1 on: February 15, 2018, 10:59:28 AM »
You never got back to me, but I ended up writing what you wanted in C#.
The import of shapefile is the easy part. The more interesting parts are the code to figure coordinate systems and draw the entities.
The thing is, dotspatial does not have an easy way to specify coord system by the "short name" like CA83-VIF.
You have to use something like Mapguide API from autodesk (free), get the number code, then feed into dotspatial.
Here is how I access the shapefile and its features, and get a simplified list of point and pline props.
You can adapt to getting text and other props of the featrures. I checked and the "gis data" is available in the feature, I just did not use it yet for anything.
Code: [Select]
//returns lists of (("point", color, width, coord)("polyline", color, width, coords)..)
        public List<object> GetFromShpFile(string shpfname, string sourceSystem, string targetSystem, bool StartingProgress) {
            if (StartingProgress) StartProgress("Reading Shapefile...", 2, true);
            //make list of return objects
            List<List<string>> retItems = new List<List<string>>();
            try {
                //get epsg codes
                MgCoordinateSystemFactory coordSysFactory = new MgCoordinateSystemFactory();
                string baseSysWkt = coordSysFactory.ConvertCoordinateSystemCodeToWkt(sourceSystem);
                string targetSysWkt = coordSysFactory.ConvertCoordinateSystemCodeToWkt(targetSystem);
                MgCoordinateSystem srcCs = coordSysFactory.Create(baseSysWkt);
                MgCoordinateSystem dstCs = coordSysFactory.Create(targetSysWkt);
                int srccode = srcCs.EpsgCode;
                int tgtcode = dstCs.EpsgCode;

                //now read into dotspacial
                Shapefile sf = Shapefile.OpenFile(shpfname);
                //look at sf.ProjectionString
                if (!File.Exists(Path.GetDirectoryName(shpfname) + "\\" + Path.GetFileNameWithoutExtension(shpfname) + ".prj"))
                    sf.Projection = ProjectionInfo.FromEpsgCode(srccode);
                sf.Reproject(ProjectionInfo.FromEpsgCode(tgtcode));

                //loop through items
                //will be DotSpatial.Topology.FeatureType. Line, Point, MultiPoint, Polygon, Unspecified
                bool DoClose = false;
                DoClose = DoProgress("Reading linework...", sf.Features.Count);
                int index = 0;
                int done = 0;
                foreach (Feature ft in sf.Features) {
                    if (!DoClose) {
                        //message every 10 items
                        if (done == 9) {
                            DoClose = DoProgressBy("Reading linework...", index);
                            done = 0;
                        }
                        DotSpatial.Topology.FeatureType typ = ft.FeatureType;
                        string color = "";
                        string width = "";
                        if (typ == FeatureType.Line || typ == FeatureType.Polygon) {
                            //coords
                            StringBuilder coords = new StringBuilder("");
                            foreach (Coordinate crd in ft.Coordinates) {
                                coords.Append(new CE.Point(crd.X, crd.Y, (double.IsNaN(crd.Z) ? 0.0 : crd.Z)).ToXYZString());
                                coords.Append(" ");
                            }
                            if (coords.Length > 0)
                                retItems.Add(new List<string>() { "polyline", color, width, coords.ToString() });
                        }
                        else if (typ == FeatureType.Point) {
                            //coords
                            StringBuilder coords = new StringBuilder("");
                            foreach (Coordinate crd in ft.Coordinates) {
                                coords.Append(new CE.Point(crd.X, crd.Y, (double.IsNaN(crd.Z) ? 0.0 : crd.Z)).ToXYZString());
                                coords.Append(" ");
                            }
                            if (coords.Length > 0)
                                retItems.Add(new List<string>() { "point", color, width, coords.ToString() });
                        }
                        else if (typ == FeatureType.MultiPoint) {
                            //coords
                            StringBuilder coords = new StringBuilder("");
                            foreach (Coordinate crd in ft.Coordinates) {
                                retItems.Add(new List<string>() { "point", color, width, new CE.Point(crd.X, crd.Y, (double.IsNaN(crd.Z) ? 0.0 : crd.Z)).ToXYZString() });
                            }
                        }
                        else if (typ == FeatureType.Unspecified) {

                        }
                    }
                    index++;
                    done++;
                }
                EndProgress(StartingProgress);
            }
            catch { }
            finally {
                CloseProgress(StartingProgress);
            }
            return new List<object>() { retItems };
        }

You can ignore the progress related items, but Norman Yuan did an excellent series on easy long process implementation at:
http://drive-cad-with-code.blogspot.ca/2015/04/showing-progress-for-long-code.html

The mapguide engine I mentioned is what autodesk uses in Map3D. Its crazy, but they actually give it away and you can use in any .net program you want.
We use it in Bricscad and basic acad for many things like making and importing kmz's.

I can't post my whole program. Our company does not sell any software yet.

James Maeding

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: Need developer for a small project in VB.NET $
« Reply #2 on: February 15, 2018, 11:26:51 AM »
BTW, Dotsoft has inexpensive complete tools for importing and exporting shapefiles, cheaper than the amount I messaged to you.
Trust me, his code is not vb.net either though. Experienced people use C# because it feels more like C++ and the good helpers are C++ people much of the time.
James Maeding

sigster

  • Newt
  • Posts: 31
Re: Need developer for a small project in VB.NET $
« Reply #3 on: February 22, 2018, 07:16:49 AM »

Hi

You must forgive that I had not contacted you I already had a programmer
Since then I have not been with the computer until now
Thanks jmaeding for your C# code

I upload the code I got from the programmer
if anyone is interested and can use the code


---
This is the reason for the interest importing with dotspatial
if you go to this web then in Developing More Software Together
you can see CAD software and many of them don't have options importing SHP file
https://www.intellicad.org/

I was finish to buy ZWCAD but I like progeCAD better

Regards
Sigster

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: Need developer for a small project in VB.NET $
« Reply #4 on: February 22, 2018, 11:19:25 AM »
No problem, I did the work for my tools, which run in acad, bricscad, and could for anything that had a .net api.

Your code skips dealing with coordinate systems - one of the trickier parts of the task.
Like I said, the problem is letting the user select a system easily, as they typically know the short name but dotspacial does not deal with short names.

Also, it does not do anything with attached data, such as setting elevations or layers.

In my mind, the dotspacial part is easy to figure out, its the coord systems, use of attached data, and drawing the items in acad that is the fun.
I already had those parts handy from my kmz import tool so just switched out the thing that generated segment info. Like playing with Legos.
James Maeding