Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine();
                ShapeToTileRendering renderer = new ShapeToTileRendering();
                SqlGeometry geom =  SqlGeometry.STGeomFromText(
                    new SqlChars(
                        new SqlString("MULTILINESTRING ((30.384520919999996 59.80926303, 30.382512119999998 59.810345999999996, 30.380262839999997 59.811639029999995, 30.37978908 59.81208003, 30.379561919999997 59.812521029999992, 30.37956516 59.812908029999996, 30.380366159999998 59.81476797, 30.380817959999998 59.815708019999995, 30.380919839999997 59.815923029999993, 30.381216839999997 59.81680296, 30.38122404 59.817422969999996, 30.381095879999997 59.817781979999992, 30.381018119999997 59.81805297, 30.38060088 59.81883696, 30.380564879999998 59.818895999999995, 30.380340959999998 59.819353019999994, 30.379961159999997 59.820206039999995, 30.37961196 59.821016039999996, 30.379339079999998 59.821782029999994, 30.378889079999997 59.82270498, 30.378455999999996 59.82356898, 30.37788792 59.82437097, 30.37726188 59.825136959999995, 30.376685159999997 59.82586902, 30.37606416 59.82661998, 30.375624959999996 59.827197959999992, 30.37499892 59.828046029999996, 30.37419 59.829446969999992, 30.373828919999998 59.830115039999995, 30.373394039999997 59.83102998, 30.372738119999998 59.833211039999995, 30.37268412 59.833364039999992, 30.372621119999998 59.833557989999996, 30.372545159999998 59.833791, 30.372460919999998 59.834046959999995, 30.372414839999998 59.83417503, 30.372101999999998 59.83514397, 30.371840999999996 59.83595397, 30.36864708 59.842442969999993, 30.368330999999998 59.84291097, 30.36764988 59.844125969999993, 30.367556999999998 59.84429202, 30.367037879999998 59.845658039999996, 30.36651804 59.84655399, 30.365706959999997 59.848254, 30.36551904 59.848963019999992, 30.365530919999998 59.849289989999995, 30.365526959999997 59.850692999999993, 30.36513384 59.851582019999995, 30.365007839999997 59.851868039999992, 30.364333919999996 59.852475, 30.364113959999997 59.85269604, 30.36410784 59.85288702, 30.36429504 59.853409019999994, 30.364288919999996 59.853500999999994, 30.364108919999996 59.85383904, 30.363968879999998 59.854103999999992, 30.363801839999997 59.854417019999993, 30.363591959999997 59.854643999999993, 30.361871159999996 59.855744969999996, 30.361730039999998 59.856040979999996, 30.36158892 59.85634104, 30.360670919999997 59.858202959999993, 30.358465919999997 59.86260702, 30.357692999999998 59.864227019999994, 30.357034919999997 59.865559019999992, 30.356945999999997 59.865708959999992, 30.356899919999996 59.86591101, 30.35647404 59.866741979999993, 30.355743959999998 59.868162989999995, 30.355220879999997 59.869191959999995, 30.354455159999997 59.870742029999995, 30.35440692 59.870870999999994, 30.353493959999998 59.872636979999996, 30.353429159999997 59.87275002, 30.353301 59.873123969999995, 30.353061959999998 59.873561999999993, 30.352727879999996 59.874068969999996, 30.351933 59.874918029999996, 30.351737879999998 59.87513601, 30.351368159999996 59.87555001, 30.35096388 59.876002979999996, 30.35044116 59.876571959999993, 30.349662839999997 59.877320039999994, 30.348977039999998 59.877995039999995, 30.34889496 59.87809503, 30.348277919999997 59.87882799, 30.348038879999997 59.87913696, 30.347979119999998 59.879247029999995, 30.34741716 59.88005901, 30.346676999999996 59.88120102, 30.345922079999998 59.882551019999994, 30.345711839999996 59.882947019999996, 30.34500984 59.884198019999992, 30.344434919999998 59.885520029999995, 30.344398919999996 59.88565404, 30.34434888 59.887295009999995, 30.34481004 59.888622959999992, 30.345045839999997 59.889466979999995, 30.34510992 59.889842009999995, 30.345116039999997 59.890086, 30.34504908 59.890566959999994), (30.38061204 59.814428039999996, 30.380756039999998 59.81477004, 30.381054839999997 59.81567697, 30.381359039999996 59.81625603, 30.38142816 59.81643396, 30.381513119999997 59.816654009999993, 30.381555959999996 59.816919959999993, 30.38159304 59.817339989999994, 30.38143212 59.817770999999993, 30.380912999999996 59.818957019999992, 30.38074704 59.819328989999995, 30.38016312 59.82054201, 30.379114079999997 59.822818019999993, 30.37876596 59.823429029999993, 30.378396959999996 59.824005029999995, 30.37827384 59.824158029999992, 30.377726999999997 59.824816019999993, 30.37723092 59.825482019999995, 30.376743119999997 59.82611202, 30.376257119999998 59.82671601, 30.375885959999998 59.827139009999996, 30.37563504 59.827467959999993, 30.375461159999997 59.827759019999995, 30.375102959999996 59.828298029999992, 30.375006839999998 59.828596019999992, 30.374864999999996 59.829077969999993, 30.374628119999997 59.82954399, 30.373770959999998 59.831350019999995, 30.37350312 59.831812979999995, 30.373094879999996 59.83323597, 30.37304196 59.83339896, 30.37301388 59.833604969999996, 30.37298292 59.833843019999996, 30.37295016 59.83408899, 30.37289112 59.834252969999994, 30.372659999999996 59.834882969999995, 30.372197039999996 59.835994019999994, 30.37177512 59.83678998, 30.37054392 59.839145009999996, 30.36891888 59.842523969999995, 30.368760839999997 59.842963979999993, 30.368490119999997 59.84357598, 30.368135879999997 59.844194009999995, 30.368040119999996 59.844384989999995, 30.366826919999998 59.846742, 30.366015119999997 59.848173989999992, 30.365937 59.848531019999996, 30.365892 59.849334989999996, 30.365885879999997 59.84973099, 30.365999999999996 59.850313019999994, 30.365913959999997 59.850557009999996, 30.365812079999998 59.850800009999993, 30.364948079999998 59.852585969999993, 30.364156079999997 59.854311989999992, 30.364067879999997 59.854463999999993, 30.36374712 59.854867019999993, 30.362553 59.856128999999996, 30.36218292 59.856596999999994, 30.35729988 59.865785999999993, 30.353637959999997 59.873174999999996, 30.353340959999997 59.873812019999995, 30.353176079999997 59.874058979999994, 30.352947119999996 59.874309, 30.351266999999996 59.876092979999996, 30.349662119999998 59.877815039999994, 30.349432079999996 59.878088999999996, 30.349275839999997 59.878186019999994, 30.348996839999998 59.878494989999993, 30.348676079999997 59.878850039999996, 30.348390959999996 59.87919501, 30.348203039999998 59.879410019999995, 30.347907839999998 59.879909969999993, 30.347156159999997 59.881292999999992, 30.34639296 59.882630039999995, 30.34616688 59.883005969999992, 30.34546884 59.884217009999993, 30.344952959999997 59.885180009999992, 30.344785919999996 59.88557304, 30.34467792 59.88616704, 30.34463292 59.887004039999994, 30.344703839999998 59.887279979999995, 30.345383159999997 59.88949596, 30.345323039999997 59.889975029999995, 30.34518408 59.890353029999993, 30.34504908 59.890566959999994, 30.34372104 59.893268039999995, 30.34351692 59.89353696, 30.343023 59.89391901, 30.341735999999997 59.89472298, 30.341615039999997 59.894830979999995, 30.34156788 59.894943029999993, 30.341553839999996 59.89532301), (30.36225708 59.853201029999994, 30.362667839999997 59.85240003, 30.362756039999997 59.852226959999996, 30.363075 59.851574009999993, 30.363616079999996 59.850462959999994, 30.363752159999997 59.850179999999995, 30.363788879999998 59.85010404, 30.364885079999997 59.847941969999994, 30.366114839999998 59.84548596, 30.366239039999996 59.845172039999994, 30.366794879999997 59.844204, 30.366848159999996 59.844057029999995, 30.36799008 59.841777959999995, 30.36866688 59.840475029999993, 30.369404879999998 59.838995969999992, 30.36985308 59.83813503, 30.370058999999998 59.83774002, 30.37094784 59.83581303), (30.356079839999996 59.865604019999992, 30.35660616 59.864591969999992, 30.357078119999997 59.863624019999996, 30.357626039999996 59.86250199, 30.358005119999998 59.86178604, 30.358344959999997 59.861145959999995, 30.35908584 59.85961002, 30.359906999999996 59.857990019999995, 30.360476159999997 59.85683604, 30.36073788 59.856356969999993, 30.36118392 59.855447969999993, 30.361607999999997 59.854548959999995, 30.36176316 59.854253039999996), (30.38795784 59.80459104, 30.388798079999997 59.80321701, 30.389784839999997 59.801147009999994, 30.391216919999998 59.797610009999993, 30.392177039999996 59.793782039999996, 30.39361812 59.788263959999995, 30.39430392 59.786109989999993, 30.395234879999997 59.784395039999993, 30.397509 59.78103597, 30.40002792 59.777304029999996, 30.40072416 59.775738029999992, 30.401135999999997 59.77412199, 30.40123284 59.773211999999994, 30.40129296 59.772311999999992, 30.401223839999997 59.771298959999996, 30.400881119999998 59.769746999999995, 30.400296119999997 59.768403029999995, 30.39975684 59.767293959999996, 30.398531039999998 59.765361029999994, 30.39753888 59.76387396, 30.396828959999997 59.76277002, 30.39597288 59.761420019999996, 30.39554484 59.76080199, 30.394397159999997 59.758981019999993, 30.39347196 59.757561989999992, 30.391760159999997 59.75488701, 30.390991919999998 59.753724029999994, 30.390301079999997 59.752752029999996), (30.390572879999997 59.75265096, 30.39218784 59.755232969999994, 30.393115919999996 59.756643, 30.39409512 59.758187039999996, 30.395081159999997 59.759724959999993, 30.395827079999997 59.760856979999993, 30.396754079999997 59.762336039999994, 30.39768216 59.763723029999994, 30.39879096 59.765427989999992, 30.39963984 59.76675297, 30.400101 59.767505009999994, 30.400586999999998 59.768319959999992, 30.400812 59.76897003, 30.40103808 59.769504989999994, 30.401448839999997 59.771077019999993, 30.401569079999998 59.772188969999995, 30.40152804 59.77330101, 30.40133112 59.774615999999995, 30.400822079999998 59.776227, 30.400058159999997 59.777719019999992, 30.396020039999996 59.783727959999993, 30.394568879999998 59.786010989999994, 30.39388308 59.78820501, 30.391080119999998 59.79879603, 30.390393959999997 59.80040604, 30.38928588 59.802780959999993, 30.389005079999997 59.80324896, 30.388192919999998 59.80462101))")), 0);
                Console.WriteLine(geom.STAsText().ToSqlString().ToString());
                renderer.DrawPartObjectShapeOnTile(geom, 9904, 5123, 14, "AA9ADBE9", "96008000", 4);
                renderer.SaveToFile(@"d:\Import\Icons\Tile_99_40980.gif", ImageFormat.Gif);

                renderer.DrawPartObjectShapeOnTile(geom, 79276, 40980, 17, "AA9ADBE9", "96008000", 4);
                renderer.SaveToFile(@"d:\Import\Icons\Tile_79276_40980.gif", ImageFormat.Gif);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
Exemple #2
0
 public static SqlBinary ShapeTile(SqlGeometry shape, SqlInt32 zoom,  SqlInt32 xTile, SqlInt32 yTile, SqlString argbFill,SqlString argbStroke,SqlInt32 strokeWidth)
 {
     SqlBinary result = null;
     using (ShapeToTileRendering paster = new ShapeToTileRendering())
     {
         using (MemoryStream ms = new MemoryStream())
         {
             try
             {
                 paster.DrawPartObjectShapeOnTile(shape, (int) xTile, (int) yTile, (int) zoom, argbFill.ToString(),
                                                  argbStroke.ToString(), (int) strokeWidth);
                 result = paster.GetBytes();
             }
             catch (System.Exception ex)
             {
                 //string innerMessage = ex.InnerException.Message;
                 //throw new Exception(string.Format("zoom: {1}; X:{2}; Y:{3} {0} , inner: {4}", shape, zoom, xTile,yTile, innerMessage));
             }
             return result;
         }
     }
 }